UVa OJ 10055 - Hashmat the Brave Warrior

来源:互联网 发布:文明5 mac 编辑:程序博客网 时间:2024/05/18 03:53

"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;}



原创粉丝点击