#include<iostream> using namespace std; void licz(int x){ if(x==1){cout<<"1";return;} if(x%2==0){ cout<<"((1+1)*"; licz(x/2); cout<<")"; } else{ cout<<"(1+"; licz(x-1); cout<<")"; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t;cin>>t; for(int i=1;i<=t;i++){ int x; cin>>x; licz(x); cout<<"\n"; } }
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 | #include<iostream> using namespace std; void licz(int x){ if(x==1){cout<<"1";return;} if(x%2==0){ cout<<"((1+1)*"; licz(x/2); cout<<")"; } else{ cout<<"(1+"; licz(x-1); cout<<")"; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t;cin>>t; for(int i=1;i<=t;i++){ int x; cin>>x; licz(x); cout<<"\n"; } } |