Here is my code for the problem : http://ideone.com/UHbff
I got WA because on Codeforces judge for input 1 10000, its giving 10007 but on ideone and my system it gives 10008. Am i using any compiler version dependent statement ?
№ | Пользователь | Рейтинг |
---|---|---|
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 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
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 |
Here is my code for the problem : http://ideone.com/UHbff
I got WA because on Codeforces judge for input 1 10000, its giving 10007 but on ideone and my system it gives 10008. Am i using any compiler version dependent statement ?
Название |
---|
http://www.cplusplus.com/reference/clibrary/cmath/pow/
http://stackoverflow.com/questions/8174909/pow-calculates-wrong
http://www.codeforces.ru/contest/205/submission/1896769
It's because of using the
pow
function. It returns double/float and in some versions (for example, MinGW) it can result in something like 999999.999999 instead of 1000000 which is rounded to 999999.Never use such floating point functions when you need to work with integers. You never know what it'll return. You'd better to write your own function
powll
which works withlong long
sAhh, i knew beforehand that pow might cause problem and i tested on MinGW-g++(windows) + g++(Linux) on several test cases before submission( indeed i shouldn't have relied on those test cases output ). I think apart from compiler its somewhat system dependent also.