http://www.luogu.org/problem/show?pid=1010
将十进制数字转为二进制,依靠二进制转十进制的思想分治即可
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ms(i,j) memset(i,j, sizeof i);
using namespace std;
int n;
int f(int a)
{
int ai[50000];
int l = -1;
while (a>0)
{
ai[++l] = a&1;
a>>=1;
}
bool fl = true;
for (int i=l;i>=0;i--)
{
if (ai[i]==1)
{
if (fl) fl = false; else putchar('+');
if (i==1) printf("2");
else if (i==0) printf("2(0)"); else
if (i>=2) {printf("2("); f(i); printf(")");}
}
}
}
int main()
{
scanf("%d", &n);
f(n);
return 0;
}