HUST Online Judge WebBoard
Problem 4180 >> 答案错误33 找不到在哪
201803010127 @ 2019-06-19 11:19:36
[ Quote ] [ Edit ] [ Delete ] 1#
#include<stdio.h>


void p(int n)
{
int i=0,a=1,s[100],j=0;
while(n>0)
{
a=1;
while(a<=n)
{
a=a*2;
i++;
}
n=n-a/2;
s[j]=i-1;
i=0;
j++;
}
for(i=0;i<j-1;i++)
{
if(s[i]>2)
{
printf("2(");
p(s[i]);
printf(")+");
}
else if((s[i]==1))
printf("2+");
else
printf("2(%d)+",s[i]);
}
if(s[i]==1)
printf("2");
else if(s[i]>2)
{
printf("2(");
p(s[i]);
printf(")+");
}
else
printf("2(%d)",s[i]);
}

int main()
{
int n;
scanf("%d",&n);
p(n);
return 0;
}