#include<iostream>
#include<string>
#include<math.h>
using namespace std;
string change(int n);
int main(void)
{
int n;
cin>>n;
cout<<change(n);
return 0;
}
string change(int n)
{
int num=n;
string s="\0";
while(num!=1 && num!=2 && num!=0)
{
int re;
for(int i=0;pow(2,i)<=num;i++)re=i;
num-=pow(2,re);
if(re==1)s+="2";
else s+="2("+change(re)+")";
if(num!=0)s+="+";
}
if(num==1)s+="2(0)";
if(num==2)s+="2";
return s;
}
ALGO-95 2的次幂表示
最新推荐文章于 2021-03-10 20:58:31 发布