Untitled
unknown
plain_text
a month ago
2.6 kB
2
Indexable
Never
#include <bits/stdc++.h> using namespace std; #define int long long void __print(int x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned int x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template <typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}'; } template <typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } #ifndef ONLINE_JUDGE #define debug(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #define debug(x...) #endif void solve() { int n; cin >> n; int a[n]; for(int i=0;i<n;i++){ cin >> a[i]; } int odd[n]; if(a[0]%2==0){ odd[0] = 0; } else{ odd[0] = 1; } for(int i=1;i<n;i++){ if(a[i]%2==0){ odd[i] = odd[i-1]; } else{ odd[i] = odd[i-1]+1; } } int sum[n]; sum[0] = a[0]; for(int i=1;i<n;i++){ sum[i] = sum[i-1]+a[i]; } for(int i=0;i<n;i++){ // debug(i); if(i==0){ cout << sum[i] << ' '; continue; } if(i==1){ if(odd[i]==1){ cout << sum[i]-1 << ' '; continue; } cout << sum[i] << ' '; continue; } if(odd[i]<=2){ cout << sum[i] << ' '; continue; } odd[i] -= 2; if(odd[i]%2==1){ odd[i]--; sum[i]--; if(odd[i]<=2){ cout << sum[i] << ' '; continue; } odd[i]-=2; int odd_pair = odd[i]/2; int num = (odd_pair/3)-(odd_pair%3==0)+2; sum[i]-=num; cout << sum[i] << ' '; continue; } else{ int odd_pair = odd[i]/2; int num = (odd_pair/3)-(odd_pair%3==0)+2; sum[i]-=num; cout << sum[i] << ' '; continue; } } cout << endl; } signed main() { int t = 1; cin >> t; while (t--) { solve(); } return 0; }
Leave a Comment