結果

問題 No.1250 汝は倍数なりや?
ユーザー tentententen
提出日時 2020-10-10 06:16:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 655 ms / 1,000 ms
コード長 574 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 71,372 KB
実行使用メモリ 65,332 KB
最終ジャッジ日時 2023-09-27 21:05:29
合計ジャッジ時間 16,672 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
56,168 KB
testcase_01 AC 104 ms
55,912 KB
testcase_02 AC 103 ms
56,336 KB
testcase_03 AC 103 ms
55,828 KB
testcase_04 AC 104 ms
55,900 KB
testcase_05 AC 107 ms
55,892 KB
testcase_06 AC 103 ms
56,040 KB
testcase_07 AC 104 ms
55,512 KB
testcase_08 AC 105 ms
55,900 KB
testcase_09 AC 112 ms
56,128 KB
testcase_10 AC 105 ms
55,844 KB
testcase_11 AC 105 ms
56,152 KB
testcase_12 AC 104 ms
55,800 KB
testcase_13 AC 105 ms
56,064 KB
testcase_14 AC 106 ms
55,956 KB
testcase_15 AC 114 ms
55,956 KB
testcase_16 AC 106 ms
55,716 KB
testcase_17 AC 109 ms
55,784 KB
testcase_18 AC 106 ms
55,668 KB
testcase_19 AC 107 ms
55,796 KB
testcase_20 AC 105 ms
55,992 KB
testcase_21 AC 104 ms
55,944 KB
testcase_22 AC 108 ms
54,288 KB
testcase_23 AC 155 ms
56,292 KB
testcase_24 AC 156 ms
56,248 KB
testcase_25 AC 160 ms
56,224 KB
testcase_26 AC 108 ms
55,908 KB
testcase_27 AC 158 ms
56,704 KB
testcase_28 AC 108 ms
55,912 KB
testcase_29 AC 135 ms
55,916 KB
testcase_30 AC 114 ms
56,188 KB
testcase_31 AC 114 ms
56,444 KB
testcase_32 AC 111 ms
55,840 KB
testcase_33 AC 655 ms
65,332 KB
testcase_34 AC 209 ms
59,204 KB
testcase_35 AC 240 ms
60,204 KB
testcase_36 AC 645 ms
65,024 KB
testcase_37 AC 516 ms
61,428 KB
testcase_38 AC 564 ms
62,136 KB
testcase_39 AC 188 ms
58,804 KB
testcase_40 AC 218 ms
59,348 KB
testcase_41 AC 591 ms
64,468 KB
testcase_42 AC 469 ms
61,040 KB
testcase_43 AC 650 ms
62,544 KB
testcase_44 AC 464 ms
60,980 KB
testcase_45 AC 431 ms
60,604 KB
testcase_46 AC 394 ms
62,212 KB
testcase_47 AC 309 ms
60,172 KB
testcase_48 AC 105 ms
55,948 KB
testcase_49 AC 104 ms
55,792 KB
testcase_50 AC 104 ms
55,916 KB
testcase_51 AC 105 ms
56,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int h = sc.nextInt();
		while (0 < n-- && h > 1) {
		    int x = sc.nextInt();
		    if (x == 0) {
		        h = 1;
		        break;
		    }
		    h /= getGCD(h, Math.abs(x));
		    
		}
		if (h == 1) {
		    System.out.println("YES");
		} else {
		    System.out.println("NO");
		}
	}
	
	static int getGCD(int x, int y) {
	    if (x % y == 0) {
	        return y;
	    } else {
	        return getGCD(y, x % y);
	    }
	}
}
0