diff --git a/P1010.cpp b/P1010.cpp new file mode 100644 index 0000000..792fa9e --- /dev/null +++ b/P1010.cpp @@ -0,0 +1,24 @@ +#include +using namespace std; +string fn(int q) +{ + if (q == 3) + return "2+2(0)"; + if (q == 2) + return "2"; + if (q == 1) + return "2(0)"; + int l = (int)log2(q); + string t1 = "2(", t2 = ")", t3 = ")+"; + if (q == (1 << l)) + return t1 + fn(l) + t2; + else + return t1 + fn(l) + t3 + fn(q - (1 << l)); +} +int main() +{ + int n; + scanf("%d", &n); + cout << fn(n) << endl; + return 0; +} \ No newline at end of file