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 <iostream> using namespace std; const int N = 32; int n, a[N]; bool isFirst = true; string s[N] = {"", "11/(45-1)*4", "-11+4-5+14", "-11-4+5+14", "11-4+5/1-4", "11-4-5+14", "1*1+45-14", "11*4+5*1*4", "1+1+(4+5)*14", "(114-51)*4+(-11-4+5+14)", "1+1-4+514", "1*(1+4)*51*4+(-11-4+5+14)", "-11+4*514+(11*-4+51-4)", "(1+1)*451*4+(11*(45-1)+4)", "114*5*14+((1+1)*4+51*4)", "1145*14+((11-4)*51-4+(11/(45-1)*4))", "114*51*4+((1+1)*4514+(11*45-14+(11*-4+51-4)))", "114*514+(11*45*14+(-11/4+51/4))", "114514+(1145*14+(1*14+514))", "114514*(-11+4-5+14)+(114*51*4+((1+1)*4514+(11+4*51*4+(11-4*5+14))))", "114514*(-11-4+5+14)+(114*514+(1+14*514+((1+145)*-(1-4)+(11/(45-1)*4))))", "114514*(11-4+5+1-4)+(1145*14+((11+451)*4+(-1-1+4+5*14)))", "114514*(1+1+4*5*1-4)+(114*51*4+(11451+4+(1145+14+(1*-1+45-14))))", "114514*(11+4*5+1+4)+(114*514+(11451+4+(114*-5*(1-4)+(-11+45+1+4))))", "114514*(1*14*5-1+4)+(114*51*4+(114*51+4+(-11+4+5+14)))", "114514*(11+45*-(1-4))+(11*4514+(114*5*14+(1+14+514+(11-4+5+1-4))))", "114514*(11+4*5*14+(-11+4-5+14))+(114*(5-1)*4+(1-14+5+14))", "114514*(114*5+14+(-11+4-5+14))+((1+1)*451*4+(11+45/1-4))", "114514*(1145+14+(1*14-5/1+4))+(1+14*514+(114-5+14))", "114514*(114*5*1*4+(11*4+5*1*4))+(1+14514+(-1-14*(5-14)))", "114514*((1145+1)*4+(114-5-1-4))+(114*51*4+(114*51+4+(11*4*5-14)))", "114514*((1+1)*4514+(11*(45-14)+(11-4+5-1-4)))+(11*4514+(114*5*14+(-(1-14)*5*14+(11-4-5+14))))"}; void print(int x) { if (isFirst) { isFirst = false; } else { if (s[x][0] != '-') cout << '+'; } cout << s[x]; } void BinarySplit(int x) { for (int i = 30; i >= 0; i--) if ((1<<i) & x) print(i+1); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; BinarySplit(n); return 0; }
|