//PA2016, runda 2, Jedynki
// Andrzej Pezarski
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;
void go(int x) {
if (x==1) printf("1");
if (x==2) printf("1+1");
if (x==3) printf("1+1+1");
if (x<4) return;
if (x%2) printf("1+");
printf("(1+1)*(");
go(x/2);
printf(")");
}
int main() {
int T;
scanf("%d", &T);
while(T--) {
int n;
scanf("%d", &n);
go(n);
printf("\n");
}
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 33 34 35 36 | //PA2016, runda 2, Jedynki // Andrzej Pezarski #include <cstdio> #include <cstdlib> #include <vector> #include <algorithm> using namespace std; void go(int x) { if (x==1) printf("1"); if (x==2) printf("1+1"); if (x==3) printf("1+1+1"); if (x<4) return; if (x%2) printf("1+"); printf("(1+1)*("); go(x/2); printf(")"); } int main() { int T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); go(n); printf("\n"); } return 0; } |
English