BITERATION #2

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 ?(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 https://www.codechef.com/viewsolution/26683236.

Edited. \hspace{0mm}

endl is very slow. Use \n

endl \hspace{0mm}

Here is my solution : https://www.codechef.com/viewsolution/26672644

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

given n find product of all factorial till N
n =3
1! * 2!*3! = 1^(3) * (2^2) * 3^(1)
here u go : https://www.geeksforgeeks.org/product-first-n-factorials/
Here is my solution : https://www.codechef.com/viewsolution/26672644 (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 https://www.codechef.com/viewsolution/26679084

Try with endl i think u will get tle

when will these problems be avalilable for practice?