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 | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
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.