#include <cstdio> using namespace std; void printJed(unsigned const k) { if(k == 1) { printf("1"); return; } else if(k == 2) { printf("1+1"); return; } if(k % 2 == 1) { printf("1+"); printJed(k-1); return; } printf("(1+1)*("); printJed(k/2); printf(")"); } void testCase(unsigned const k) { printJed(k); printf("\n"); } void testCase() { unsigned k; scanf("%u", &k); testCase(k); } int main() { unsigned char t; scanf("%hhu", &t); while(t--) testCase(); }
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 34 35 36 37 38 39 40 | #include <cstdio> using namespace std; void printJed(unsigned const k) { if(k == 1) { printf("1"); return; } else if(k == 2) { printf("1+1"); return; } if(k % 2 == 1) { printf("1+"); printJed(k-1); return; } printf("(1+1)*("); printJed(k/2); printf(")"); } void testCase(unsigned const k) { printJed(k); printf("\n"); } void testCase() { unsigned k; scanf("%u", &k); testCase(k); } int main() { unsigned char t; scanf("%hhu", &t); while(t--) testCase(); } |