這題只要將兩個數絕對值相減即可,唯一的陷阱就是在於數值範圍,剛好到2^32,就連unsigned int也會爆,所以請用long long吧!
C++(0.136)
/*******************************************************/
/* UVa 10055 Hashmat the brave warrior */
/* Author: Maplewing [at] knightzone.studio */
/* Version: 2011/11/29 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
long long warrior1, warrior2;
while( scanf( "%lld%lld", &warrior1, &warrior2 ) != EOF ){
printf( "%lld\n", (warrior1 > warrior2)? warrior1-warrior2 : warrior2-warrior1 );
}
return 0;
}