Inventon Problem Code: INVENTO

help

#1

Link to the problem: https://www.codechef.com/problems/INVENTO

Hi community,

Can anybody of you provide me a solid reason for why my solution is failing?

Link to the solution: https://www.codechef.com/viewsolution/24277333


#2

I might be wrong. Can it be an error due to overflow when trying to put the value 10 ^ 18 in long double? I mean, in the long double we have 15 significant digits compared to 18 of ll int. So there may be some power of two that we lose when we convert input to long double.


#3

yeah first problem is because of long double but when i submitted your code after changing long double to long log int again i got the WA may be because value passed in log2() function is overflowing then i just used the position of leftmost bit to get the answer . my solution


#4

long double provides more precision and accuracy as compared to long long int. So, it can’t be the case at all.

Moreover, try these four cases:
288230376151711744
288230376151711745
576460752303423487
576460752303423488

DESIRED Output:
59
59
59
60


#5

Could you please list atleast one case where my solution will provide a wrong answer?