結果

問題 No.1946 ロッカーの問題
ユーザー masayamatumasayamatu
提出日時 2022-06-20 20:41:29
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 1,725 bytes
コンパイル時間 11,430 ms
コンパイル使用メモリ 168,832 KB
実行使用メモリ 37,404 KB
最終ジャッジ日時 2024-04-21 10:09:55
合計ジャッジ時間 16,520 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
33,664 KB
testcase_01 AC 53 ms
37,404 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (87 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
//using static CompLib.CompLib;
//using DataStructure;

namespace atcoder
{
    class Program
    {
        const int intMax = 1000000000;
        const long longMax = 2000000000000000000;
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = new int[NM[1]];
            if (NM[1] != 0)
                A = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var cnt = new int[NM[0] + 1];
            var open = new bool[NM[0] + 1];
            for (int i = 0; i < NM[1]; i++)
            {
                open[A[i]] = true;
            }
            cnt[1] = 1;
            for (int i = 2; i <= NM[0]; i++)
            {
                int idx = 1;
                while (i / idx >= 1)
                {
                    if (idx == i) break;
                    if (i % idx == 0)
                        cnt[i / idx]++;
                    idx++;
                }
            }
            int ans = 0;
            for (int i = NM[0]; i >= 0; i--)
            {
                if ((open[i] && cnt[i] % 2 == 0) || (!open[i] && cnt[i] % 2 == 1))
                {
                    ans++;
                    int idx = 1;
                    while (idx != i && i / idx > 0)
                    {
                        if (i % idx == 0)
                        {
                            cnt[i / idx]--;
                        }
                        idx++;
                    }
                }
            }
            Console.WriteLine(ans);

        }
    }
}
0