Sample Input
1 3 4
Sample Output
1 7 11
#include<stdio.h>
char a[3]={'1','4','7'};
void main()
{
int i,n;
while(scanf("%d",&n)!=EOF)
{
if(n<=3){printf("%c
",a[n-1]);continue;}
int b[100],t=0;
n--;
while(n/3)
{
b[t++]=n%3;
n=n/3-1;
}
b[t]=n%3;
while(t>=0)printf("%c",a[b[t--]]);
printf("
");
}
}