close
題目概要:
計算出Hashmat的士兵跟敵對士兵的數量差。
解題方向:
把輸入的2個數字相減即可。因為最大值是2^32,所以需要用long來做存放。
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Java | |
import java.util.Scanner; | |
class uva10055{ | |
public static void main(String args[]){ | |
Scanner sc=new Scanner(System.in); | |
while(sc.hasNextLong()){ | |
long a=sc.nextLong(),b=sc.nextLong(); //讀入2個數字。 | |
//Output | |
System.out.println(Math.abs(a-b)); | |
} | |
} | |
} |
文章標籤
全站熱搜