https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2319
這題是2016 10/04 CPE第四題 利用大數去判斷是有整除就好了 另外除數是0時直接跳出迴圈Wonderful num.equals(new BigInteger("0")) 這裡也可以用compareTo去比對 還有每組資料第二行的第一個數字是接下來有多少個數字並不是被除數
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n=Integer.parseInt(scn.nextLine());
while(n--!=0){
BigInteger num=new BigInteger(scn.nextLine());
boolean b=true;
String s[]=scn.nextLine().split(" ");
for(int i=1;i<s.length;i++){
if(num.equals(new BigInteger("0")))
break;
if(!(num.mod(new BigInteger(s[i])).equals(new BigInteger("0")))){
b=false;
break;
}
}
if(b)
System.out.println(num+" - "+"Wonderful.");
else
System.out.println(num+" - "+"Simple.");
}
}
/*題目:Q:11344 - The Huge One
作者:1010
時間:西元 2016 年 10 月 */
}