結果

問題 No.103 素因数ゲーム リターンズ
ユーザー mbanmban
提出日時 2017-04-28 10:53:11
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 1,117 bytes
コンパイル時間 3,769 ms
コンパイル使用メモリ 105,488 KB
実行使用メモリ 23,676 KB
最終ジャッジ日時 2023-10-11 17:26:02
合計ジャッジ時間 5,136 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,616 KB
testcase_01 AC 62 ms
23,472 KB
testcase_02 AC 61 ms
21,496 KB
testcase_03 AC 62 ms
21,524 KB
testcase_04 AC 61 ms
21,520 KB
testcase_05 AC 63 ms
23,580 KB
testcase_06 AC 61 ms
21,532 KB
testcase_07 AC 62 ms
23,512 KB
testcase_08 AC 62 ms
21,596 KB
testcase_09 AC 61 ms
19,428 KB
testcase_10 AC 62 ms
21,472 KB
testcase_11 AC 63 ms
21,604 KB
testcase_12 AC 62 ms
21,596 KB
testcase_13 AC 63 ms
21,512 KB
testcase_14 AC 63 ms
21,604 KB
testcase_15 AC 62 ms
19,816 KB
testcase_16 AC 62 ms
21,580 KB
testcase_17 AC 63 ms
23,676 KB
testcase_18 AC 63 ms
21,644 KB
testcase_19 AC 63 ms
21,644 KB
testcase_20 AC 63 ms
21,724 KB
testcase_21 AC 63 ms
21,540 KB
testcase_22 AC 64 ms
23,628 KB
testcase_23 AC 64 ms
21,576 KB
testcase_24 AC 62 ms
21,836 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

public class Program
{
    static int N = int.Parse(Console.ReadLine());
    static int[] M = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    static public void Main(string[] args)
    {
        Console.WriteLine(Grundy(M) == 0 ? "Bob" : "Alice");
    }

    static int Grundy(int n)
    {
        var map = new Dictionary<int, int>();
        for (int i = 2; n != 1; i++)
        {
            if (n % i == 0)
            {
                map[i] = 0;
                while (n % i == 0)
                {
                    map[i]++;
                    n /= i;
                }
            }
        }

        int result = 0;
        foreach (var p in map)
        {
            result ^= p.Value % 3;
        }
        return result;
    }

    static int Grundy(int[] m)
    {
        int ans = 0;
        foreach (int i in m)
        {
            ans ^= Grundy(i);
        }
        return ans;
    }
}

0