#include <bits/stdc++.h>
using namespace std;
void rek(int x)
{
if(x==2)
{
cout<<"(1+1)";
}
if(x==3)
{
cout<<"(1+1+1)";
}
if(x>3)
{
cout<<"(";
if(x%2==1)
{
cout<<"1+"; x=x-1;
}
cout<<"(1+1)*";
x=x/2;
rek(x);
cout<<")";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int a,b;
cin>>b;
for(int i=0; i<b; i++)
{
cin>>a;
if(a==1){cout<<"1";}
if(a>1){rek(a);}
cout<<endl;
}
//system ("PAUSE");
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 | #include <bits/stdc++.h> using namespace std; void rek(int x) { if(x==2) { cout<<"(1+1)"; } if(x==3) { cout<<"(1+1+1)"; } if(x>3) { cout<<"("; if(x%2==1) { cout<<"1+"; x=x-1; } cout<<"(1+1)*"; x=x/2; rek(x); cout<<")"; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int a,b; cin>>b; for(int i=0; i<b; i++) { cin>>a; if(a==1){cout<<"1";} if(a>1){rek(a);} cout<<endl; } //system ("PAUSE"); return 0; } |
English