|
- #include<iostream>
- using namespace std;
- int i,n,s,a[20001]={},j=0;
- int cf(int a,int b)
- {
- int c=2;
- for(int x=2;x<=b;x++)c*=2;
- if(b==0)c=1;
- return c;
- }
- void kj(int e)
- {
- int k=1,y;
- if(e==0)return;
- i=0;
- j++;
- do i++;
- while(cf(2,i)<=e);
- y=--i;
- a[j]=y;
- if(a[j]==0)cout<<"2(0)";
- if(a[j]==1)cout<<"2";
- if(a[j]>1)
- {
- cout<<"2(";
- kj(a[j]);
- cout<<")";
- }
- if(e!=cf(2,y))
- {
- cout<<"+";
- kj(e-cf(2,y));
- }
- }
- int main()
- {
- cin>>n;
- kj(n);
- }
复制代码 |
|