結果

問題 No.1665 quotient replace
ユーザー bluemeganebluemegane
提出日時 2021-09-09 09:14:29
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,432 bytes
コンパイル時間 1,701 ms
コンパイル使用メモリ 63,688 KB
実行使用メモリ 58,652 KB
最終ジャッジ日時 2023-08-28 12:58:55
合計ジャッジ時間 14,864 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 235 ms
29,548 KB
testcase_01 AC 236 ms
25,188 KB
testcase_02 AC 56 ms
20,548 KB
testcase_03 AC 288 ms
23,352 KB
testcase_04 AC 300 ms
25,548 KB
testcase_05 AC 259 ms
25,280 KB
testcase_06 AC 791 ms
25,828 KB
testcase_07 AC 341 ms
25,472 KB
testcase_08 AC 567 ms
23,720 KB
testcase_09 AC 2,348 ms
29,084 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        getAns(n, a);
    }
    static void getAns(int n, int[] a)
    {
        if (n == 1) { Console.WriteLine(a[0] == 1 ? "black" : "white"); return; }
        var s = GeneratePrime(1000000);
        var w = new int[n];
        for (int i = 0; i < n; i++) w[i] = calc(a[i], s);
        var x = w[0] ^ w[1];
        for (int i = 2; i < n; i++) x ^= w[i];
        Console.WriteLine(x == 0 ? "black" : "white");
    }
    static int calc(int t, List<int> s)
    {
        var p = 0;
        var count = 0;
        while (true)
        {
            if (t < s[p]) break;
            if (t % s[p] == 0)
            {
                t /= s[p];
                count++;
            }
            else p++;
        }
        return count;
    }
    static List<int> GeneratePrime(int m)
    {
        var a = new List<int>();
        int p;
        var sqrtMax = Sqrt(m);
        var s = Enumerable.Range(2, m - 1).ToList();
        do
        {
            p = s.First();
            a.Add(p);
            s.RemoveAll(n => n % p == 0);
        }
        while (p < sqrtMax);
        a.AddRange(s);
        return a;
    }
}
0