結果

問題 No.1250 汝は倍数なりや?
ユーザー bluemeganebluemegane
提出日時 2020-10-10 07:47:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 168 ms / 1,000 ms
コード長 807 bytes
コンパイル時間 1,884 ms
コンパイル使用メモリ 67,540 KB
実行使用メモリ 41,188 KB
最終ジャッジ日時 2023-09-27 21:08:11
合計ジャッジ時間 8,092 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,620 KB
testcase_01 AC 59 ms
18,652 KB
testcase_02 AC 57 ms
20,736 KB
testcase_03 AC 56 ms
20,716 KB
testcase_04 AC 57 ms
20,764 KB
testcase_05 AC 57 ms
22,784 KB
testcase_06 AC 57 ms
18,732 KB
testcase_07 AC 56 ms
18,776 KB
testcase_08 AC 56 ms
20,732 KB
testcase_09 AC 58 ms
22,756 KB
testcase_10 AC 56 ms
20,724 KB
testcase_11 AC 56 ms
20,732 KB
testcase_12 AC 57 ms
20,740 KB
testcase_13 AC 57 ms
20,636 KB
testcase_14 AC 58 ms
20,712 KB
testcase_15 AC 57 ms
22,728 KB
testcase_16 AC 58 ms
20,728 KB
testcase_17 AC 56 ms
18,644 KB
testcase_18 AC 57 ms
20,768 KB
testcase_19 AC 57 ms
22,776 KB
testcase_20 AC 57 ms
20,848 KB
testcase_21 AC 56 ms
20,848 KB
testcase_22 AC 56 ms
22,732 KB
testcase_23 AC 66 ms
20,800 KB
testcase_24 AC 64 ms
20,840 KB
testcase_25 AC 65 ms
20,872 KB
testcase_26 AC 64 ms
22,828 KB
testcase_27 AC 64 ms
22,880 KB
testcase_28 AC 64 ms
20,788 KB
testcase_29 AC 65 ms
20,804 KB
testcase_30 AC 65 ms
20,792 KB
testcase_31 AC 64 ms
20,780 KB
testcase_32 AC 64 ms
20,812 KB
testcase_33 AC 168 ms
40,364 KB
testcase_34 AC 98 ms
28,328 KB
testcase_35 AC 130 ms
40,920 KB
testcase_36 AC 154 ms
39,312 KB
testcase_37 AC 127 ms
34,972 KB
testcase_38 AC 132 ms
37,412 KB
testcase_39 AC 98 ms
28,464 KB
testcase_40 AC 105 ms
32,700 KB
testcase_41 AC 144 ms
38,404 KB
testcase_42 AC 103 ms
27,056 KB
testcase_43 AC 164 ms
41,188 KB
testcase_44 AC 103 ms
29,088 KB
testcase_45 AC 139 ms
39,368 KB
testcase_46 AC 92 ms
25,508 KB
testcase_47 AC 112 ms
37,456 KB
testcase_48 AC 57 ms
22,832 KB
testcase_49 AC 56 ms
20,620 KB
testcase_50 AC 56 ms
20,732 KB
testcase_51 AC 57 ms
22,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;

public class Hello
{
    static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var h = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, h, a);
    }
    static void getAns(int n, int h, int[] a)
    {
        for (int i = 0; i < n; i++)
        {
            var t = gcd(h, a[i]);
            h /= t;
            if (h == 1) { Console.WriteLine("YES"); return; }
        }
        Console.WriteLine("NO");
    }
    static int gcd(int a, int b)
    {
        if (a < b) return gcd(b, a);
        while (b != 0)
        {
            var w = a % b;
            a = b;
            b = w;
        }
        return a;
    }
}
0