HackerEarth The Great Kian problem solution YASH PAL, 31 July 2024 In this HackerEarth The Great Kian problem solution The great Kian is looking for a smart prime minister. He’s looking for a guy who can solve the OLP (Old Legendary Problem). OLP is an old problem (obviously) that no one was able to solve it yet (like P=NP). But still, you want to be the prime minister really bad. So here’s the problem: Given the sequence a1, a2, …, an find the three values a1 + a4 + a7 + …, a2 + a5 + a8 + … and a3 + a6 + a9 + … (these summations go on while the indexes are valid). HackerEarth The Great Kian problem solution. #include <bits/stdc++.h>#include <ext/pb_ds/assoc_container.hpp>#include <ext/pb_ds/tree_policy.hpp>using namespace __gnu_pbds;using namespace std;#define Foreach(i, c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))#define rof(i,a,b) for(int (i)=(a);(i) > (b); --(i))#define rep(i, c) for(auto &(i) : (c))#define x first#define y second#define pb push_back#define PB pop_back()#define iOS ios_base::sync_with_stdio(false)#define sqr(a) (((a) * (a)))#define all(a) a.begin() , a.end()#define error(x) cerr << #x << " = " << (x) <<endl#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )n";#define errop(a) cerr<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )n";#define coud(a,b) cout<<fixed << setprecision((b)) << (a)#define L(x) ((x)<<1)#define R(x) (((x)<<1)+1)#define umap unordered_map#define double long doubletypedef long long ll;typedef pair<int,int>pii;typedef vector<int> vi;typedef complex<double> point;template <typename T> using os = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;template <class T> inline void smax(T &x,T y){ x = max((x), (y));}template <class T> inline void smin(T &x,T y){ x = min((x), (y));}ll x[3];int main(){ iOS; int n, a; cin >> n; For(i,0,n){ cin >> a; x[i % 3] += (ll)a; } For(i,0,3) cout << x[i] << ' '; cout << endl; return 0;} Second solution #include<bits/stdc++.h>const int N = 100031;using namespace std;int n;int ar[N];long long res[10];int main(){ ios_base::sync_with_stdio(0); //cin.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> ar[i]; } for (int i = 0; i < 3; i++) { int cur = i; do { res[i] += ar[cur]; cur += 3; } while (cur < n); } for (int i = 0; i < 3; i++) { if (i) cout << " "; cout << res[i]; } cout << endl; return 0;} coding problems