#include <iostream> #include <cstdlib> #include <vector> using namespace std; void rozloz(int k){ if (k == 1) cout << 1; else { cout << '('; if (k % 2 == 1) cout << "1+"; cout << "(1+1)*"; rozloz(k/2); cout << ')'; } } int main(void) { int t; cin >> t; for (int i = 0; i < t; i++){ int k; cin >> k; rozloz(k); cout << 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 27 28 29 30 31 32 | #include <iostream> #include <cstdlib> #include <vector> using namespace std; void rozloz(int k){ if (k == 1) cout << 1; else { cout << '('; if (k % 2 == 1) cout << "1+"; cout << "(1+1)*"; rozloz(k/2); cout << ')'; } } int main(void) { int t; cin >> t; for (int i = 0; i < t; i++){ int k; cin >> k; rozloz(k); cout << endl; } return 0; } |