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
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…