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

Edited. \hspace{0mm}

endl is very slow. Use \n

endl :frowning: \hspace{0mm}

Here is my solution :
Read from Line 286 . :slight_smile:

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

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 :
Here is my solution : (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

Try with endl i think u will get tle

when will these problems be avalilable for practice?