Xorry - 2, Code not working

Problem : Xorry 2 Practice Coding Problem - CodeChef

My logic : Iterate through the binary of the given number, and count the number of zeros after 2 1s have appeared in the original binary, to ensure that the 2 answer numbers are smaller than the original. The resultant answer is 2^count of zeros>

My code works in the sample test cases, i even checked (after the tournament) using a for loop for various big numbers, and it all checks out, yet its failing test case 1. PLEASE HELP



You are having oveflow issue, just did cout<<(1LL<<ans2) in your code it passed

1 Like