您的位置:首页 > 其它

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还是够了)

1004676910055Hashmat the Brave WarriorAcceptedC++0.3842012-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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  numbers input byte 2010