#include<algorithm> #include<cassert> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) #define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i) // x >= 1 void print(int x) { if (x == 1) { cout << "1"; return; } if (x & 1) { cout << "(1+"; } cout << "((1+1)*"; print(x/2); cout << ")"; if (x & 1) { cout << ")"; } } void doit() { int x; scanf("%d", &x); print(x); cout << endl; } int main() { int T; scanf("%d", &T); while (T--) doit(); 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 51 52 53 54 55 | #include<algorithm> #include<cassert> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> using namespace std; typedef long long LL; typedef vector<int> VI; #define REP(i,n) for(int i=0;i<(n);i++) #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define FORD(i,a,b) for(int i=(a);i>=(b);i--) #define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i) // x >= 1 void print(int x) { if (x == 1) { cout << "1"; return; } if (x & 1) { cout << "(1+"; } cout << "((1+1)*"; print(x/2); cout << ")"; if (x & 1) { cout << ")"; } } void doit() { int x; scanf("%d", &x); print(x); cout << endl; } int main() { int T; scanf("%d", &T); while (T--) doit(); return 0; } |