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