結果

問題 No.1946 ロッカーの問題
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-04 14:50:52
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 439 ms / 3,000 ms
コード長 1,125 bytes
コンパイル時間 6,894 ms
コンパイル使用メモリ 158,624 KB
実行使用メモリ 214,620 KB
最終ジャッジ日時 2024-02-04 14:51:03
合計ジャッジ時間 11,100 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
32,676 KB
testcase_01 AC 73 ms
32,676 KB
testcase_02 AC 78 ms
32,932 KB
testcase_03 AC 380 ms
67,576 KB
testcase_04 AC 76 ms
33,060 KB
testcase_05 AC 82 ms
34,340 KB
testcase_06 AC 82 ms
34,468 KB
testcase_07 AC 81 ms
34,212 KB
testcase_08 AC 141 ms
47,012 KB
testcase_09 AC 320 ms
66,912 KB
testcase_10 AC 293 ms
66,124 KB
testcase_11 AC 81 ms
34,468 KB
testcase_12 AC 112 ms
40,228 KB
testcase_13 AC 74 ms
32,676 KB
testcase_14 AC 75 ms
32,676 KB
testcase_15 AC 77 ms
33,188 KB
testcase_16 AC 75 ms
32,676 KB
testcase_17 AC 210 ms
56,996 KB
testcase_18 AC 439 ms
214,620 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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 int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var a = new int[0];
        if (m == 0) ReadLine();
        else a = NList;
        var dp = new bool[n + 1];
        foreach (var ai in a) dp[ai] = true;
        var ans = 0;
        for (var i = n; i > 0; --i)
        {
            if (dp[i])
            {
                foreach (var p in PList(i)) dp[p] = !dp[p];
            }
            else ++ans;
        }
        WriteLine(ans);
    }
    static List<int> PList(int n)
    {
        var ans = new List<int>();
        for (var i = 1; i * i <= n; ++i)
        {
            if (n % i == 0)
            {
                ans.Add(i);
                if (i * i < n) ans.Add(n / i);
            }
        }
        return ans;
    }
}
0