竹園論壇

標題: Q10055 - Hashmat the brave warrior [打印本頁]

作者: HSCHE    時間: 2014-4-29 11:49
標題: Q10055 - Hashmat the brave warrior
Hashmat是一個勇敢的將領,他帶著年輕的士兵從這個城市移動到另一個城市與敵人對抗。在打仗之前他會計算己方與敵方士兵的數目差距,來決定是要開打或不開打。Hashmat的士兵數絕不會比敵人的士兵數大。
Input
每組測試資料1列,有2個整數,代表Hashmat及敵人的士兵數或反之。這些數不會超過2[sup]32[/sup]。
Output
對每組測試資料請輸出Hashmat與敵人士兵數目的差(正數)。
Sample input
10 1214 10100 200
Sample Output
24100

在此附上題目連結
UVA:http://uva.onlinejudge.org/external/100/10055.html
LUCKY CAT:http://luckycat.kshs.kh.edu.tw/homework/q10055.htm
解題感想:這題其實可以直接打在UVA上也不怕WA掉,只能說根本水題,唯一要注意的可能只有printf "lld"&"I64d"的轉換了
AC CODE:
#include<iostream>
  • #include<cstdio>
  • #include<cstring>
  • #include<cmath>
  • #include<stack>
  • #include<vector>
  • using namespace std;
  • int main()
  • {
  •         long long int a,b,ans;
  •         while(~scanf("%lld%lld",&a,&b))
  •         {
  •                 if(a>b) ans=a-b;
  •                 else ans=b-a;
  •                 printf("%lld\n",ans);
  •         }
  • }








  • 歡迎光臨 竹園論壇 (http://forum.tfcis.org/) Powered by Discuz! X3.2