Page 1 of 1

Problem K - time limit exceeded

Posted: Sat Feb 24, 2007 10:16 pm
by AjJi
Hi everybody,
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;
}
Thank you :)

Posted: Sun Feb 25, 2007 1:12 pm
by ayon
input will terminate with a negative value, not just -1