結果
| 問題 | No.103 素因数ゲーム リターンズ | 
| コンテスト | |
| ユーザー |  mban | 
| 提出日時 | 2017-04-28 10:53:11 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 32 ms / 5,000 ms | 
| コード長 | 1,117 bytes | 
| コンパイル時間 | 956 ms | 
| コンパイル使用メモリ | 110,448 KB | 
| 実行使用メモリ | 29,312 KB | 
| 最終ジャッジ日時 | 2024-09-13 16:25:54 | 
| 合計ジャッジ時間 | 2,729 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 20 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
    }
}
            
            
            
        