#include <bits/stdc++.h> #define _2137 0 #define mod 1000000007 using namespace std; int main() { int n,offset=1; scanf("%d",&n); while(offset<n) {offset*=2;} int pow=offset*2; int tree[pow]; memset(tree,0,sizeof tree); //out<<pow<<" "<<offset<<endl; for(int i=0,a,b;i<n;++i){ a=b=i+offset; scanf("%d",&tree[a]); while(a>1){ a/=2; tree[a]+=tree[b]; tree[a]%=mod; } } for(int i=1,go=1;i<offset;){ for(int j=0;j<go;++j){ //cout<<tree[i]<<" "; if(tree[i]&1) cout<<"FF "; else cout<<"TT "; ++i; } go*=2; cout<<endl; } for(int i=offset;i<pow;++i){ if(tree[i]!=0){ if(tree[i]&1) cout<<"FF "; else cout<<"TT "; } else cout<<"00 "; } return _2137; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #include <bits/stdc++.h> #define _2137 0 #define mod 1000000007 using namespace std; int main() { int n,offset=1; scanf("%d",&n); while(offset<n) {offset*=2;} int pow=offset*2; int tree[pow]; memset(tree,0,sizeof tree); //out<<pow<<" "<<offset<<endl; for(int i=0,a,b;i<n;++i){ a=b=i+offset; scanf("%d",&tree[a]); while(a>1){ a/=2; tree[a]+=tree[b]; tree[a]%=mod; } } for(int i=1,go=1;i<offset;){ for(int j=0;j<go;++j){ //cout<<tree[i]<<" "; if(tree[i]&1) cout<<"FF "; else cout<<"TT "; ++i; } go*=2; cout<<endl; } for(int i=offset;i<pow;++i){ if(tree[i]!=0){ if(tree[i]&1) cout<<"FF "; else cout<<"TT "; } else cout<<"00 "; } return _2137; } |