WA IN FLAGS... PLZ HELP

Here are two soln’s that are almost same…

1 is ac :-- CodeChef: Practical coding for everyone

nd other shows wa :-- CodeChef: Practical coding for everyone …(mine)

the one that shows wa is built with respect to constraints… the constraints that shows max value of n as 10000 is wrong(i suppose correct me if i m wrong)…

Plz tell me the error in my code it cost me 3 WA’s

Thnx for ur help

the prob is that when you pass ‘n’ as only int in the expression, it evaluates to generate an int ans. This works for small cases but for n=10,000 the ans evaluated will be much bigger…if you had typecast the result of expression as long long int then even your first solution would have worked…in the 2nd solution as n is already passed as long long int the expression is evaluated to long long int and hence it works…

You can get your further doubts cleared on the Editorial page of the problem. Closing this question.