#include <bits/stdc++.h> using namespace std; const int N = 2005; const int inf = 1e9+7; int n, result; void rec(int n) { if (n == 1) cout << 1; else { cout << "((1+1)*"; rec(n / 2); if (n & 1) cout << "+1"; cout << ")"; } } void solve() { cin >> n; result = 0; rec(n); cout << '\n'; } int main() { ios::sync_with_stdio(false); int z; cin >> z; while (z--) solve(); 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 | #include <bits/stdc++.h> using namespace std; const int N = 2005; const int inf = 1e9+7; int n, result; void rec(int n) { if (n == 1) cout << 1; else { cout << "((1+1)*"; rec(n / 2); if (n & 1) cout << "+1"; cout << ")"; } } void solve() { cin >> n; result = 0; rec(n); cout << '\n'; } int main() { ios::sync_with_stdio(false); int z; cin >> z; while (z--) solve(); return 0; } |