UVa OJ 10055 - Hashmat the Brave Warrior
2012-10-22 05:20
453 查看
"The input numbers are not greater than 2^32."
int为4个byte,正好是2^(4*8),但是要包括负数,所以int可以存的最大正数是2^(4*8)/2-1,即2147483647。用unsigned int则差1,因为0也要包括在内。
所以还是安心用long吧(我用vs2010和mingw查的sizeof(long)居然也是4。。。,UVaOJ用的cygwin还是够了)
int为4个byte,正好是2^(4*8),但是要包括负数,所以int可以存的最大正数是2^(4*8)/2-1,即2147483647。用unsigned int则差1,因为0也要包括在内。
所以还是安心用long吧(我用vs2010和mingw查的sizeof(long)居然也是4。。。,UVaOJ用的cygwin还是够了)
10046769 | 10055 | Hashmat the Brave Warrior | Accepted | C++ | 0.384 | 2012-04-28 04:50:08 |
#include<iostream> #include<cstdlib> using namespace std; int main(){ long p1,p2; while(cin>>p1>>p2){ cout<<labs(p2-p1)<<endl; } return 0; }
相关文章推荐
- UVA oj 10055 Hashmat the Brave Warrior(坑题)
- UVa OJ 10055-Hashmat the Brave Warrior
- UVA OJ: 10055 - Hashmat the Brave Warrior
- UVa 10055 Hashmat the Brave Warrior (water ver.)
- uva 10055 Hashmat the Brave Warrior
- Hashmat the brave warrior - UVa10055
- UVA 10055(Hashmat the brave warrior )
- UVA 10055 Hashmat the brave warrior
- Hashmat the brave warrior(UVa10055)简单题
- UVA 10055 - Hashmat the Brave Warrior
- [结题报告]10055 - Hashmat the Brave Warrior Time limit: 3.000 seconds
- 10055 - Hashmat the Brave Warrior
- 10055-Hashmat the Brave Warrior
- 10055 - Hashmat the Brave Warrior
- 算法竞赛入门经典-前四章-UVa10055 - Hashmat the Brave Warrior-勇士Hashmat-难度1
- uva 10055 Hashmat the Brave Warrior
- UVA 10055 - Hashmat the Brave Warrior
- uva-10055 - Hashmat the Brave Warrior
- uva 10055 - Hashmat the Brave Warrior
- UVA10055 Hashmat the Brave Warrior【水题】