#include <stdio.h>
int threeCarry[19];
int creat()
{
int i, j;
for (i = 0, j = 1; i < 19; i ++, j *= 3)
threeCarry[i] = j;
}
int main()
{
creat();
int n, i;
while(scanf("%d", &n) == 1)
{
if (n < 0) break;
int isPut = 0;
if (n == 0)
{
printf("0\n");
continue;
}
for (i = 18; i >= 0; i --)
if (n / threeCarry[i] > 0)
printf("%d", n / threeCarry[i]), n %= threeCarry[i], isPut = 1;
else if (isPut)
printf("0");
printf("\n");
}
return 0;
}
回目錄
回首頁
沒有留言 :
張貼留言