結果

問題 No.1250 汝は倍数なりや?
ユーザー tentententen
提出日時 2022-09-16 15:29:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 302 ms / 1,000 ms
コード長 1,359 bytes
コンパイル時間 3,409 ms
コンパイル使用メモリ 73,940 KB
実行使用メモリ 60,908 KB
最終ジャッジ日時 2023-08-23 09:53:31
合計ジャッジ時間 10,376 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,100 KB
testcase_01 AC 42 ms
49,184 KB
testcase_02 AC 42 ms
49,632 KB
testcase_03 AC 43 ms
49,256 KB
testcase_04 AC 44 ms
47,616 KB
testcase_05 AC 44 ms
49,220 KB
testcase_06 AC 43 ms
49,156 KB
testcase_07 AC 44 ms
49,156 KB
testcase_08 AC 43 ms
49,604 KB
testcase_09 AC 43 ms
49,144 KB
testcase_10 AC 44 ms
49,240 KB
testcase_11 AC 43 ms
49,404 KB
testcase_12 AC 43 ms
49,416 KB
testcase_13 AC 44 ms
49,192 KB
testcase_14 AC 45 ms
49,396 KB
testcase_15 AC 44 ms
49,192 KB
testcase_16 AC 44 ms
49,156 KB
testcase_17 AC 44 ms
49,152 KB
testcase_18 AC 44 ms
49,060 KB
testcase_19 AC 43 ms
49,104 KB
testcase_20 AC 44 ms
49,148 KB
testcase_21 AC 44 ms
47,580 KB
testcase_22 AC 45 ms
49,180 KB
testcase_23 AC 52 ms
49,140 KB
testcase_24 AC 51 ms
49,288 KB
testcase_25 AC 56 ms
50,480 KB
testcase_26 AC 45 ms
49,248 KB
testcase_27 AC 53 ms
47,056 KB
testcase_28 AC 45 ms
49,320 KB
testcase_29 AC 48 ms
49,200 KB
testcase_30 AC 46 ms
47,436 KB
testcase_31 AC 45 ms
49,168 KB
testcase_32 AC 46 ms
49,020 KB
testcase_33 AC 302 ms
60,608 KB
testcase_34 AC 150 ms
54,620 KB
testcase_35 AC 186 ms
58,896 KB
testcase_36 AC 274 ms
60,908 KB
testcase_37 AC 244 ms
55,328 KB
testcase_38 AC 252 ms
57,304 KB
testcase_39 AC 141 ms
54,740 KB
testcase_40 AC 151 ms
54,692 KB
testcase_41 AC 272 ms
57,720 KB
testcase_42 AC 190 ms
54,944 KB
testcase_43 AC 286 ms
58,076 KB
testcase_44 AC 190 ms
55,352 KB
testcase_45 AC 225 ms
60,368 KB
testcase_46 AC 189 ms
55,260 KB
testcase_47 AC 179 ms
57,104 KB
testcase_48 AC 43 ms
49,264 KB
testcase_49 AC 44 ms
49,392 KB
testcase_50 AC 43 ms
49,112 KB
testcase_51 AC 44 ms
49,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int h = sc.nextInt();
        for (int i = 0; i < n && h > 1; i++) {
            h /= getGCD(Math.abs(sc.nextInt()), h);
        }
        if (h == 1) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
    
    static int getGCD(int x, int y) {
        if (y == 0) {
            return x;
        } else {
            return getGCD(y, x % y);
        }
    }
}
    
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0