You are not logged in. Please login at to post your questions!


Why am I getting TLE?

Can anyone tell me why I am getting TLE in ?

asked 19 Sep '14, 19:49

jsk1_s's gravatar image

accept rate: 0%

  • In your code, 'b' represents 'A' as mentioned in the problem. A < 10^9.
  • And your solution has the loop while(k--){}. Hence your solution will take approximately A steps, or in easier way, the number of steps of your problem is of the order A. Hence your code is an O(A) solution. For algorithm analysis:
  • Now, we all know the computation power of a processor is also limited. Assume 1 sec ~ 10^8 operations per second . (for SPOJ old server it is 4*10^6). Keep this in mind while solving any problem.

  • So if A < 10^6 then your solution will pass, but here A<10^9, hence it is giving 'Time Limit Exceeded'. Try to come with a optimal solution :)

  • Hint: This problem has a O(k) solution and k, according to problem statement is < 100 :D

answered 19 Sep '14, 20:42

ketanhwr's gravatar image

accept rate: 15%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 19 Sep '14, 19:49

question was seen: 699 times

last updated: 19 Sep '14, 20:42