BITERATION #2

Problem Link

AC Solution

TLE Solutoin

Can anyone help me out with the difference between this AC solution and mine TLE solution ?


endl is very slow. Use \n
These are common mistakes people do.

1 Like

How will that make any difference ?

1 Like

What does it do ?:pensive:(20 char)

I did the exact same solution but got TLE and also I did the declared of n inside loop. Here is my solution.

I will explain u…don’t worry…

But why…is it gives tle just declared inside loop…

1 Like

I am getting the same issue. You can check my solution at CodeChef: Practical coding for everyone.

Edited. \hspace{0mm}

endl is very slow. Use \n

endl :frowning: \hspace{0mm}

Here is my solution : CodeChef: Practical coding for everyone
Read from Line 286 . :slight_smile:

  1. Dont use endl . It flushes the output
  2. use register int in case of for loops

https://www.codechef.com/viewsolution/26686257

Same issue.

given n find product of all factorial till N
n =3
1! * 2!*3! = 1^(3) * (2^2) * 3^(1)
here u go : Product of first N factorials - GeeksforGeeks
Here is my solution : CodeChef: Practical coding for everyone (read from line 286)

But I had used ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); so why endl gives TLE?

Please someone list these type of ideas like “endl gives tle” to prevent from errors in future?

Becz you are calculating factorial for each number in each test case, instead of calculating it again & again store the factorial in an array and use it later.
Here’s my code CodeChef: Practical coding for everyone

Try with endl i think u will get tle

when will these problems be avalilable for practice?