marbles question,it is displaying wrong answer,can someone help.below link is solution link

look for overflows. try this test case:


100 100

Your loop conditions are wrong, causing overflow.

The variable i in the for loop should go upto min(k-1, n-k) instead of just k-1.

So, change this line

for(ll i = 0; i < k-1; i++)

to this

for(ll i = 0; i < min(k-1, n-k); i++)

And your code will get Accepted (AC).

@c_utkarsh, bayya thank you!!I was breaking my head to figure out what was going wrong,thank you keep helping,many like me need your help.cheers!

1 Like