結果

問題 No.1665 quotient replace
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-05 00:07:57
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 556 ms / 3,000 ms
コード長 1,716 bytes
コンパイル時間 6,816 ms
コンパイル使用メモリ 158,508 KB
実行使用メモリ 180,120 KB
最終ジャッジ日時 2024-01-05 00:08:15
合計ジャッジ時間 18,364 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
32,548 KB
testcase_01 AC 71 ms
32,548 KB
testcase_02 AC 76 ms
32,548 KB
testcase_03 AC 81 ms
37,216 KB
testcase_04 AC 81 ms
37,224 KB
testcase_05 AC 83 ms
37,160 KB
testcase_06 AC 89 ms
38,436 KB
testcase_07 AC 85 ms
37,404 KB
testcase_08 AC 86 ms
37,932 KB
testcase_09 AC 95 ms
42,476 KB
testcase_10 AC 240 ms
85,904 KB
testcase_11 AC 407 ms
122,400 KB
testcase_12 AC 114 ms
51,508 KB
testcase_13 AC 556 ms
143,000 KB
testcase_14 AC 528 ms
145,564 KB
testcase_15 AC 543 ms
145,568 KB
testcase_16 AC 523 ms
142,996 KB
testcase_17 AC 532 ms
145,568 KB
testcase_18 AC 82 ms
35,040 KB
testcase_19 AC 75 ms
34,212 KB
testcase_20 AC 78 ms
35,296 KB
testcase_21 AC 77 ms
35,424 KB
testcase_22 AC 77 ms
34,468 KB
testcase_23 AC 76 ms
36,064 KB
testcase_24 AC 78 ms
35,040 KB
testcase_25 AC 77 ms
34,468 KB
testcase_26 AC 85 ms
37,472 KB
testcase_27 AC 84 ms
38,180 KB
testcase_28 AC 93 ms
42,504 KB
testcase_29 AC 108 ms
48,180 KB
testcase_30 AC 266 ms
108,668 KB
testcase_31 AC 337 ms
130,384 KB
testcase_32 AC 389 ms
123,900 KB
testcase_33 AC 211 ms
74,612 KB
testcase_34 AC 346 ms
114,728 KB
testcase_35 AC 345 ms
110,864 KB
testcase_36 AC 350 ms
114,140 KB
testcase_37 AC 334 ms
108,688 KB
testcase_38 AC 352 ms
113,792 KB
testcase_39 AC 281 ms
102,216 KB
testcase_40 AC 288 ms
102,216 KB
testcase_41 AC 279 ms
102,216 KB
testcase_42 AC 74 ms
32,548 KB
testcase_43 AC 73 ms
180,120 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (95 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();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var mlist = GetMinPDivList(a.Max());
        var ans = 0;
        foreach (var ai in a)
        {
            if (ai > 1) ans ^= PDiv(ai, mlist).Count;
        }
        WriteLine(ans == 0 ? "black" : "white");
    }
    static int[] GetMinPDivList(int max)
    {
        var minPDivList = new int[max + 1];
        for (var i = 0; i <= max; ++i) minPDivList[i] = i;

        for (var i = 2; i * i <= max; ++i) if (minPDivList[i] == i)
        {
            for (var j = i * i; j <= max; j += i) if (minPDivList[j] == j)
            {
                minPDivList[j] = i;
            }
        }
        return minPDivList;
    }
    static int GetMinPDiv(int n, int min)
    {
        var p = min;
        while ((long)p * p <= n)
        {
            if (n % p == 0) return p;
            ++p;
        }
        return n;
    }
    static List<int> PDiv(int n, int[] minPDivList)
    {
        var p = minPDivList[n];
        if (n == p)
        {
            var dic = new List<int>();
            dic.Add(p);
            return dic;
        }
        else
        {
            var dic = PDiv(n / p, minPDivList);
            dic.Add(p);
            return dic;
        }
    }
}
0