結果
| 問題 | No.153 石の山 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-02 17:03:36 |
| 言語 | C# (.NET 10.0.201) |
| 結果 |
AC
|
| 実行時間 | 70 ms / 5,000 ms |
| コード長 | 1,916 bytes |
| 記録 | |
| コンパイル時間 | 7,507 ms |
| コンパイル使用メモリ | 174,248 KB |
| 実行使用メモリ | 194,600 KB |
| 最終ジャッジ日時 | 2026-03-24 01:07:55 |
| 合計ジャッジ時間 | 11,420 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (87 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
public class Program
{
static int[] memo = { };
static int GetGrundy(int count)
{
if(memo[count] != -1)
return memo[count];
Dictionary<int, int> dic = new Dictionary<int, int>();
if (count >= 2 && count % 2 == 0)
{
int grundy = GetGrundy(count / 2) ^ GetGrundy(count / 2);
if(!dic.ContainsKey(grundy))
dic.Add(grundy, 1);
}
if (count >= 2 && count % 2 == 1)
{
int grundy = GetGrundy(count / 2) ^ GetGrundy(count / 2 + 1);
if (!dic.ContainsKey(grundy))
dic.Add(grundy, 1);
}
if (count >= 3 && count % 3 == 0)
{
int grundy = GetGrundy(count / 3) ^ GetGrundy(count / 3) ^ GetGrundy(count / 3);
if (!dic.ContainsKey(grundy))
dic.Add(grundy, 1);
}
if (count >= 3 && count % 3 == 1)
{
int grundy = GetGrundy(count / 3) ^ GetGrundy(count / 3) ^ GetGrundy(count / 3 + 1);
if (!dic.ContainsKey(grundy))
dic.Add(grundy, 1);
}
if (count >= 3 && count % 3 == 2)
{
int grundy = GetGrundy(count / 3) ^ GetGrundy(count / 3 + 1) ^ GetGrundy(count / 3 + 1);
if (!dic.ContainsKey(grundy))
dic.Add(grundy, 1);
}
int ret = 0;
while (true)
{
if(!dic.ContainsKey(ret))
break;
ret++;
}
memo[count] = ret;
return ret;
}
static void Main()
{
int N = int.Parse(Console.ReadLine());
memo = new int[N + 1];
for (int i = 0; i <= N; i++)
memo[i] = -1;
if (GetGrundy(N) != 0)
Console.WriteLine("A");
else
Console.WriteLine("B");
}
}