結果

問題 No.1665 quotient replace
ユーザー bluemeganebluemegane
提出日時 2021-09-09 08:06:00
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,431 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 66,092 KB
実行使用メモリ 97,164 KB
最終ジャッジ日時 2023-08-28 11:40:53
合計ジャッジ時間 12,500 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
21,544 KB
testcase_01 AC 69 ms
21,460 KB
testcase_02 AC 55 ms
20,640 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 55 ms
18,604 KB
testcase_19 AC 56 ms
18,756 KB
testcase_20 AC 56 ms
20,772 KB
testcase_21 AC 57 ms
22,772 KB
testcase_22 AC 56 ms
20,840 KB
testcase_23 AC 56 ms
20,776 KB
testcase_24 AC 55 ms
20,724 KB
testcase_25 AC 55 ms
22,704 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 56 ms
20,712 KB
testcase_43 AC 70 ms
21,632 KB
権限があれば一括ダウンロードができます

ソースコード

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(100000);
        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