結果
| 問題 | No.1250 汝は倍数なりや? | 
| コンテスト | |
| ユーザー |  tenten | 
| 提出日時 | 2020-10-10 06:16:23 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 927 ms / 1,000 ms | 
| コード長 | 574 bytes | 
| コンパイル時間 | 2,578 ms | 
| コンパイル使用メモリ | 75,772 KB | 
| 実行使用メモリ | 56,908 KB | 
| 最終ジャッジ日時 | 2024-12-21 05:06:01 | 
| 合計ジャッジ時間 | 20,555 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 49 | 
ソースコード
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);
	    }
	}
}
            
            
            
        