#include <cstdio> #include <string> using namespace std; void SolveCase(); int main() { int t; scanf("%d", &t); for(int i = 0; i < t; ++i) SolveCase(); return 0; } void SolveCase() { int k; scanf("%d", &k); int n = 30; while(!(k & (1<<--n))); string front; string back; while(n--) { bool isOne = k & (1<<n); if(isOne) front += '(', back += "*(1+1)+1)"; else back += "*(1+1)"; } printf("%s1%s\n", front.c_str(), back.c_str()); }
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 | #include <cstdio> #include <string> using namespace std; void SolveCase(); int main() { int t; scanf("%d", &t); for(int i = 0; i < t; ++i) SolveCase(); return 0; } void SolveCase() { int k; scanf("%d", &k); int n = 30; while(!(k & (1<<--n))); string front; string back; while(n--) { bool isOne = k & (1<<n); if(isOne) front += '(', back += "*(1+1)+1)"; else back += "*(1+1)"; } printf("%s1%s\n", front.c_str(), back.c_str()); } |