結果

問題 No.2682 Visible Divisible
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-20 21:27:58
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 369 ms / 2,000 ms
コード長 1,103 bytes
コンパイル時間 9,370 ms
コンパイル使用メモリ 158,448 KB
実行使用メモリ 208,328 KB
最終ジャッジ日時 2024-03-20 21:28:14
合計ジャッジ時間 13,153 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 341 ms
61,016 KB
testcase_01 AC 332 ms
61,316 KB
testcase_02 AC 352 ms
61,544 KB
testcase_03 AC 339 ms
61,732 KB
testcase_04 AC 160 ms
60,980 KB
testcase_05 AC 216 ms
61,000 KB
testcase_06 AC 300 ms
61,716 KB
testcase_07 AC 337 ms
60,276 KB
testcase_08 AC 77 ms
32,548 KB
testcase_09 AC 76 ms
32,548 KB
testcase_10 AC 78 ms
32,548 KB
testcase_11 AC 313 ms
61,004 KB
testcase_12 AC 369 ms
61,240 KB
testcase_13 AC 332 ms
60,564 KB
testcase_14 AC 282 ms
61,208 KB
testcase_15 AC 361 ms
60,464 KB
testcase_16 AC 175 ms
208,328 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (108 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var a = NList;
        var lcm = 1L;
        for (var i = 0; i < n; ++i)
        {
            if (a[i] % k == 0)
            {
                WriteLine("Yes");
                return;
            }
            lcm = LCM(lcm, GCD(a[i], k));
            if (lcm % k == 0)
            {
                WriteLine("Yes");
                return;
            }
        }
        WriteLine("No");
    }
    static long LCM(long a, long b)
    { checked {
        var gcd = GCD(a, b);
        return a / gcd * b;
    } }
    static long GCD(long a, long b)
    {
        if (a < b) return GCD(b, a);
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }
}
 
0