Https://www.codechef.com/viewsolution/27512806 (DOR)

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

can anyone tell me what is wrong in my code
I am following the approach given in the editoial

Here’s a test case:

393383587145601330 571238254289132474

The answer should be:

576460752303423487

but your code produces:

576460752303423488

Off by 1 digit.

Spoiler

Line 45

How about changing that to ans += 1LLU << i;?
If you refer to this, you’ll know that pow is simply not enough for dealing with such large numbers.

1 Like

ok thanks
my solution got accepted after I multiplied 2 repeatedly in for loop rather than using pow function

1 Like