#include<stdio.h>

int q[100][1000= {0};
const int INF = 10;
void pp( int t)
{
    __int64 re 
= 1;
    
int k = t;
    
int i;
    q[k][
0= 1;
    
while(t--)
    
{
        
for(i=0; i<1000 ; i++)
        
{
            
while(q[k][i] >= INF)
            
{
                q[k][i
+1++;
                q[k][i] 
-= INF;
            }

            q[k][i] 
*= 3;
        }

        
for(i=0; i<1000; i++)
        
{
            
while(q[k][i] >= INF)
            
{
                q[k][i
+1++;
                q[k][i] 
-= INF;
            }

        }

    }

}


int main()
{
    __int64 n;
    
int i;
    
for(i=0; i<= 64; i++)
        pp(i);
    
while(1)        
    
{
        scanf(
"%I64d",&n);
        
if( n == 0 ) break;
        printf(
"{");
        
if ( n > 0 )
        
{
            n
--;
            
int t = 0;
            
int temp = 0;        
            
while(n)
            
{
                
if( n&1 )
                
{
                    
if(temp)
                        printf(
",");
                    printf(
" ");
                    
int aa = 0;
                    
for(i=999; i>=0; i--)
                    
{
                        
if(q[t][i])
                            aa 
= 1;
                        
if(aa)
                        
{
                            printf(
"%d",q[t][i]);
                        }

                    }

                    temp 
= 1;
                }

                t
++;
                n 
>>= 1;
            }

        }

        printf(
" }\n");
    }

    
return 0;
}

数学问题吧,和二进制有关系。地址:http://acm.pku.edu.cn/JudgeOnline/problem?id=1906