Problem K - time limit exceeded

Post here if you don't find any other place for your post. But please, stay on-topic: algorithms, programming or something related to this web site and its services.

Moderator: Board moderators

Post Reply
AjJi
New poster
Posts: 1
Joined: Sat Feb 24, 2007 10:09 pm

Problem K - time limit exceeded

Post by AjJi » Sat Feb 24, 2007 10:16 pm

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 :)

ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
Location: buet, dhaka, bangladesh

Post by ayon » Sun Feb 25, 2007 1:12 pm

input will terminate with a negative value, not just -1
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program

Post Reply

Return to “Other words”