提交时间:2024-08-20 21:30:38

运行 ID: 173557

#include<iostream> #include<cstdio> #include<cstdlib> #include<cstdlib> #define N 1000010 using namespace std; void calculate(int n,int step) { if(n==0) return; calculate(n/2,step+1); if(n%2) { if(n/2) cout<<"+"; if(step==1) cout<<"2"; else { cout<<"2("; if(step==0) cout<<"0"; else calculate(step,0); cout<<")"; } } } int main() { int n; cin>>n; calculate(n,0); cout<<endl; return 0; }