Time limit exceed

https://ide.codingblocks.com/s/38880 - source code
https://hack.codingblocks.com/contests/c/255/68 - problem

my answer is correct but it is showing time limit exceed … also i am not able to think of alternate solution. What should i do?

Hey Kushal, there is no need to loop over all the numbers in the series.
Hint is a simple mathematical formula exists for this series based on if ‘n’ is odd or even.
You just have to find that formula now.

1 Like

thanks for the hint bhaia … but i am not able to think of that formula … in problem statement also it is given that use series formula … and while looking on the time alloted… i thught it was talking about power function… please help me by mentioning that formula?

Hey Kushal, it’s okay if you are unable to figure out the formula i’m helping you with it.
if n is odd then f(n) = (n-1)/2;
if n is even then f(n) = (n)/2;

And btw i’m a girl :slight_smile:

oops ty so much for the help di :slight_smile: