# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 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.