mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P1010 幂次方
R38856378
This commit is contained in:
parent
290b77dae3
commit
fbe2b155c3
24
problem/P1010/P1010.cpp
Normal file
24
problem/P1010/P1010.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
// R38856378
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
string d(int x, int i, string s) {
|
||||
if (x == 0) {
|
||||
return "0";
|
||||
}
|
||||
do {
|
||||
if (x & 1) {
|
||||
s = (i == 1 ? "2" : "2(" + d(i, 0, "") + ")") + (s == "" ? "" : "+") + s;
|
||||
}
|
||||
} while (++i, x >>= 1);
|
||||
return s;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
cout << d(n, 0, "") << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user