#include <bits/stdc++.h> using namespace std; typedef long long int64; #define DEBUG(x) cerr << #x << " = " << x << endl; #define REP(x, n) for(__typeof(n) x = 0; x < (n); ++x) #define FOR(x, b, e) for(__typeof(b) x = (b); x != (e); x += 1 - 2 * ((b) > (e))) const int INF = 1000000001; const double EPS = 10e-9; #ifndef CATCH_TEST int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; REP(o, t) { int n; cin >> n; int open = 0; while (n > 2) { if (n & 1) { cout << "1+"; --n; } else { cout << "(1+1)*("; ++open; n /= 2; } } switch (n) { case 1: cout << "1"; break; case 2: cout << "1+1"; break; } REP(x, open) { cout << ")"; } cout << endl; } return 0; } #endif
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 | #include <bits/stdc++.h> using namespace std; typedef long long int64; #define DEBUG(x) cerr << #x << " = " << x << endl; #define REP(x, n) for(__typeof(n) x = 0; x < (n); ++x) #define FOR(x, b, e) for(__typeof(b) x = (b); x != (e); x += 1 - 2 * ((b) > (e))) const int INF = 1000000001; const double EPS = 10e-9; #ifndef CATCH_TEST int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin >> t; REP(o, t) { int n; cin >> n; int open = 0; while (n > 2) { if (n & 1) { cout << "1+"; --n; } else { cout << "(1+1)*("; ++open; n /= 2; } } switch (n) { case 1: cout << "1"; break; case 2: cout << "1+1"; break; } REP(x, open) { cout << ")"; } cout << endl; } return 0; } #endif |