結果

問題 No.1250 汝は倍数なりや?
ユーザー tenten
提出日時 2020-10-10 06:08:54
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 495 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 74,880 KB
実行使用メモリ 57,060 KB
最終ジャッジ日時 2024-07-20 15:35:57
合計ジャッジ時間 17,603 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48 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, Math.abs(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