#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int k; cin >> k; string b=""; while (k) { b = (k%2 ? "1" : "0")+b; k/=2; } //cout << b << endl; string s="1"; for (int k=1;k<b.length();k++) { if (b[k]=='0') s="("+s+"*(1+1))"; else s="("+s+"*(1+1)+1)"; } cout << s << 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 | #include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int k; cin >> k; string b=""; while (k) { b = (k%2 ? "1" : "0")+b; k/=2; } //cout << b << endl; string s="1"; for (int k=1;k<b.length();k++) { if (b[k]=='0') s="("+s+"*(1+1))"; else s="("+s+"*(1+1)+1)"; } cout << s << endl; } return 0; } |