提交时间:2024-08-20 11:18:21
运行 ID: 168520
#include<bits/stdc++.h> using namespace std; void dfs(int n){ while(n>0){ int temp=1,x=1; while(temp<=n){ x++; temp*=2; } x--; if(x==1){ cout<<"2(0)"; } else if(x==2){ cout<<"2"; } else{ cout<<"2("; dfs(temp/4); cout<<")"; } n-=temp/2; if(n!=0){ cout<<"+"; } } } int main(){ int n; cin>>n; dfs(n); }