I get A time limit exceeded but i don't know why here is the problem & code:
problem :
http://online-judge.uva.es/contest/data ... set/k.html
Code :
Code: Select all
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,a;
int ter[20];
long int n;
scanf("%d",&n);
while(n!=-1)
{
i=0;
do {
a = n/3;
ter[i]=n%3;
n =a;
i++;
} while(a!=0);
for(j=i-1;j>=0;j--) printf("%d",ter[j]);
printf("\n");
scanf("%d",&n);
}
return 0;
}
