# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3831 |
3 | Radewoosh | 3646 |
4 | jqdai0815 | 3620 |
4 | Benq | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | gamegame | 3386 |
10 | ksun48 | 3373 |
# | User | Contrib. |
---|---|---|
1 | cry | 164 |
1 | maomao90 | 164 |
3 | Um_nik | 163 |
4 | atcoder_official | 160 |
5 | -is-this-fft- | 158 |
6 | awoo | 157 |
7 | adamant | 156 |
8 | TheScrasse | 154 |
8 | nor | 154 |
10 | Dominater069 | 153 |
Name |
---|
Auto comment: topic has been updated by Sujay_27 (previous revision, new revision, compare).
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
sum
can be equal to $$$2 \cdot 10^{14}$$$ in some test cases and thusmid * mid
may 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.
Yeah got it! Thanks mate.
instead of binary search,why arent you using sqrt its much simpler code
yea I figured that, but wanted to try with binary search
it works if you use unsigned long long instead of signed long long (long long)
Oh ok
nah mate, unsigned long long only goes up to about 1.84*10^19, which is still nowhere near 10^28.