#include "stdafx.h"
#include "iostream"
typedef __int64 INT64;
void HeroNeedThree(INT64* subset, unsigned int n)
{
// base3[k]=3^k
static INT64 base3[32]=
{
0x1,0x3,0x9,0x1b,0x51,0xf3,0x2d9,0x88b,
0x19a1,0x4ce3,0xe6a9,0x2b3fb,0x81bf1,0x1853d3,0x48fb79,0xdaf26b,
0x290d741,0x7b285c3,0x17179149,0x4546b3db,0xcfd41b91,0x26f7c52b3,0x74e74f819,0x15eb5ee84b,
0x41c21cb8e1,0xc546562aa3,0x24fd3027fe9,0x6ef79077fbb,0x14ce6b167f31,0x3e6b41437d93,0xbb41c3ca78b9,0x231c54b5f6a2b
};
// base2[k]=2^k
static unsigned int base2[32]=
{
0x1,0x2,0x4,0x8,0x10,0x20,0x40,0x80,
0x100,0x200,0x400,0x800,0x1000,0x2000,0x4000,0x8000,
0x10000,0x20000,0x40000,0x80000,0x100000,0x200000,0x400000,0x800000,
0x1000000,0x2000000,0x4000000,0x8000000,0x10000000,0x20000000,0x40000000,0x80000000
};
INT64 num=0;
n--;
for(int i=31;i>=0;--i)
{
if(n & base2[i]) // 计算n的第i位上是否是1
{
subset[++num]=base3[i];
}
}
subset[0]=num;
}
int main(int argc, char* argv[])
{
unsigned int n;
INT64 subset[40];
std::cin>>n;
HeroNeedThree(subset,n);
printf("%I64d\n",subset[0]);
for(INT64 i=0;i<subset[0];++i)
printf("%I64d,",subset[i+1]);
return 0;
}
倚天照海花无数,流水高山心自知。