結果

問題 No.1250 汝は倍数なりや?
ユーザー tentententen
提出日時 2020-10-10 06:15:22
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 574 bytes
コンパイル時間 1,851 ms
コンパイル使用メモリ 71,428 KB
実行使用メモリ 64,880 KB
最終ジャッジ日時 2023-09-27 21:05:11
合計ジャッジ時間 15,924 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,280 KB
testcase_01 AC 118 ms
55,608 KB
testcase_02 AC 115 ms
55,608 KB
testcase_03 AC 117 ms
56,128 KB
testcase_04 AC 120 ms
56,072 KB
testcase_05 AC 118 ms
55,728 KB
testcase_06 AC 119 ms
55,908 KB
testcase_07 AC 119 ms
55,984 KB
testcase_08 AC 119 ms
55,972 KB
testcase_09 AC 117 ms
56,128 KB
testcase_10 AC 121 ms
55,472 KB
testcase_11 AC 120 ms
55,696 KB
testcase_12 AC 118 ms
55,464 KB
testcase_13 AC 118 ms
55,912 KB
testcase_14 AC 121 ms
56,036 KB
testcase_15 AC 122 ms
56,104 KB
testcase_16 AC 120 ms
56,036 KB
testcase_17 AC 119 ms
55,924 KB
testcase_18 AC 117 ms
56,072 KB
testcase_19 AC 120 ms
55,748 KB
testcase_20 AC 120 ms
55,788 KB
testcase_21 RE -
testcase_22 AC 121 ms
56,320 KB
testcase_23 AC 176 ms
55,800 KB
testcase_24 AC 178 ms
56,848 KB
testcase_25 AC 184 ms
56,404 KB
testcase_26 AC 121 ms
55,756 KB
testcase_27 AC 178 ms
56,272 KB
testcase_28 AC 122 ms
56,048 KB
testcase_29 AC 143 ms
55,904 KB
testcase_30 AC 131 ms
55,692 KB
testcase_31 AC 130 ms
55,880 KB
testcase_32 AC 126 ms
55,916 KB
testcase_33 AC 747 ms
64,880 KB
testcase_34 AC 235 ms
59,700 KB
testcase_35 AC 268 ms
60,216 KB
testcase_36 AC 674 ms
64,668 KB
testcase_37 AC 572 ms
61,980 KB
testcase_38 AC 586 ms
63,008 KB
testcase_39 AC 206 ms
59,208 KB
testcase_40 AC 237 ms
59,532 KB
testcase_41 AC 643 ms
64,616 KB
testcase_42 AC 531 ms
60,748 KB
testcase_43 AC 753 ms
64,536 KB
testcase_44 AC 527 ms
60,536 KB
testcase_45 AC 485 ms
60,640 KB
testcase_46 AC 442 ms
60,460 KB
testcase_47 AC 330 ms
60,584 KB
testcase_48 AC 119 ms
55,940 KB
testcase_49 AC 119 ms
55,976 KB
testcase_50 AC 120 ms
56,152 KB
testcase_51 AC 118 ms
54,248 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 == 1) {
		        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