I am getting expected output but then also verdict is WRONG ANSWER

https://www.codechef.com/viewsolution/52877133

I am getting expected output but then also verdict is WRONG ANSWER.

Please run this code let me know if any TEST CASE is not working.

For ‘mn’ it should be

if(x*2<=k*x)
      mn=x*2;
else
      mn=x*(x+1);

Can you please help me regarding the THOUGHT PROCESS i.e logic in this by giving a test case example.

Means, which test case we have to think about.

The only problem I can see in your code is use of int for storing variables. Even if kx <=1e9 is given, but kx*(k*x - 1) will cause integer overflow. So, use of long long will solve the problem.

THANK YOU ,THANK YOU ,THANK YOU ,THANK YOU ,THANK YOU

THIS IS WORKING .

1 Like

Not sure if this answers your question, but the output can be bigger than int, so I used long for all the variables.

I am getting expected output but then also verdict is WRONG ANSWER

https://www.codechef.com/viewsolution/53032751