https://www.codechef.com/viewsolution/35145244
Can someone see where my code is wrong?
Read the problem statement again, word-for-word
The biggest mistake is that you’re using pow()
.
Let’s say that you want to store 2^{30}. You would simply do pow(2, 30)
right?
No. pow(2, 30)
gives 1.07374e+09
instead of 1073741824
.
Change the line to long long power = (1LL << i);
. I’m not sure about your logic though. First fix this issue and try.
You’re still using pow
Changing that still causes WA in Sub task 1. I don’t see how a smaller subtask is failing.
https://www.codechef.com/viewsolution/35157678
Probably line 22
Yup that was it. Thanks.