Hello folks, Need some help in debugging.. The question is on the right : Ques This is the code I submitted : Code I don't know why I'm getting signed integer overflow, inspite of having all the variables as long long. Can someone enlighten me on what I'm missing. [contest:918][problem:1915C]
Sum can be 1e14 which would lead to overflow you can set a upperlimit of 1e9
The maximum value that a long long variable can have is $$$2^{63} - 1$$$. In your code
sumcan be equal to $$$2 \cdot 10^{14}$$$ in some test cases and thusmid * midmay get bigger than the long long limit.In worst case, the sum can be 2*10^14 then the mid will be 10^14. mid * mid will be 10^28. long long can hold at most 10^18.
instead of binary search,why arent you using sqrt its much simpler code