結果

問題 No.1250 汝は倍数なりや?
ユーザー tenten
提出日時 2020-10-10 06:07:41
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 5,526 ms
コンパイル使用メモリ 74,176 KB
実行使用メモリ 41,652 KB
最終ジャッジ日時 2024-07-20 15:35:36
合計ジャッジ時間 10,724 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 22 RE * 1
権限があれば一括ダウンロードができます

ソースコード

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) {
		    h /= getGCD(h, sc.nextInt());
		    
		}
		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