题目
代码
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
#include<fstream>
#include<complex>
#include<algorithm>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
string cal(int x){
int i=0;string s;
if(x==0) return "0";
while(1){
if(x&1) s=(i==1?"2":"2("+cal(i)+")")+(s==""?"":"+")+s;
++i,x>>=1;
if(x<=0) break;
}
return s;
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int n;
cin>>n;
cout<<cal(n)<<endl;
return 0;
}