#include <iostream> using namespace std; long long x, t, ile; void pies(int x){ if(x==2) cout<<"(1+1)"; else if(x==1) cout<<"1"; else if(x%2==0){ cout<<"(1+1)*"; pies(x/2); } else{ cout<<"(1+"; pies(x-1); cout<<")"; } } void kot(int x){ if(x==2) ile+=2; else if(x==1) ile++; else if(x%2==0){ ile+=2; kot(x/2); } else{ ile++; kot(x-1); } } int main(){ ios_base::sync_with_stdio(0); cin>>t; while(t--){ cin>>x; pies(x); cout<<"\n"; } return 0; }
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 | #include <iostream> using namespace std; long long x, t, ile; void pies(int x){ if(x==2) cout<<"(1+1)"; else if(x==1) cout<<"1"; else if(x%2==0){ cout<<"(1+1)*"; pies(x/2); } else{ cout<<"(1+"; pies(x-1); cout<<")"; } } void kot(int x){ if(x==2) ile+=2; else if(x==1) ile++; else if(x%2==0){ ile+=2; kot(x/2); } else{ ile++; kot(x-1); } } int main(){ ios_base::sync_with_stdio(0); cin>>t; while(t--){ cin>>x; pies(x); cout<<"\n"; } return 0; } |