UVa11344 - The Huge One

来源:互联网 发布:北宋出相 知乎 编辑:程序博客网 时间:2024/05/18 06:25
import java.util.*;import java.math.BigInteger;import java.io.*;class Main{public static void main(String[] args) {Scanner cin;int t;boolean flag;int n;int div;int i;cin = new Scanner(System.in);t = cin.nextInt();while (t-- > 0) {String s = cin.next();if (s.compareTo("0") == 0) {n = cin.nextInt();while (n-- > 0) {div = cin.nextInt();}System.out.println(s + " - Wonderful.");continue;}flag = true;n = cin.nextInt();BigInteger num = new BigInteger(s);for (i = 0; i < n && flag; i++) {div = cin.nextInt();if (div == 1) {continue;} else if (div == 2) {int tail = s.charAt(s.length() - 1) - '0';if (tail % 2 != 0) flag = false;} else {if (num.remainder(BigInteger.valueOf(div)).compareTo(BigInteger.ZERO) != 0) flag = false;}}for (; i < n; i++){div = cin.nextInt();}if (flag) {System.out.println(s + " - Wonderful.");} else {System.out.println(s + " - Simple.");}}}}

0 0
原创粉丝点击