提交时间:2024-08-20 11:33:29
运行 ID: 168621
#include<iostream> using namespace std; int n; void solve(int a){ if (a==0) cout<<0; else if(a==1) cout<<"2(0)"; else if(a==2) cout<<"2"; else{ int t=a,i=0; while(t) t>>=1,i++; bool f=1; for(i=i-1;i>=0;i--) if((a>>i)&1) { if(f) f=0; else cout<<"+"; if(i==1) cout<<2; else cout<<"2(",solve(i),cout<<")"; } } } int main(){ cin>>n; solve(n); }