#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t --> 0) { int k; cin >> k; int o = 0; while (k > 0) { if (k % 2) { cout << "1"; if (k > 1) cout << "+"; } k /= 2; if (k > 0) { cout << "(1+1)*"; if (k != 1) { cout << "("; o++; } } } while (o --> 0) cout << ")"; cout << endl; } 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 | #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t --> 0) { int k; cin >> k; int o = 0; while (k > 0) { if (k % 2) { cout << "1"; if (k > 1) cout << "+"; } k /= 2; if (k > 0) { cout << "(1+1)*"; if (k != 1) { cout << "("; o++; } } } while (o --> 0) cout << ")"; cout << endl; } return 0; } |