結果
| 問題 |
No.153 石の山
|
| コンテスト | |
| ユーザー |
kou6839
|
| 提出日時 | 2015-03-28 00:04:30 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 127 ms / 5,000 ms |
| コード長 | 661 bytes |
| コンパイル時間 | 2,825 ms |
| コンパイル使用メモリ | 85,356 KB |
| 実行使用メモリ | 41,400 KB |
| 最終ジャッジ日時 | 2024-10-14 14:33:54 |
| 合計ジャッジ時間 | 6,334 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
import java.math.BigInteger;
import java.util.*;
public class Main {
static int rec(int x){
if(grandy[x]!=-1) return grandy[x];
Set<Integer> set = new HashSet<>();
set.add(rec(x/2)^rec((x+1)/2));
if(x>=3){
set.add(rec(x/3)^rec((x+1)/3)^rec((x+2)/3));
}
int res=0;
while(set.contains(res)) res++;
return grandy[x]=res;
}
static int[] grandy;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
grandy = new int[101];
Arrays.fill(grandy, -1);
grandy[1]=0;
for(int i=1;i<101;i++) grandy[i]=rec(i);
if(grandy[sc.nextInt()]==0){
System.out.println("B");
}else{
System.out.println("A");
}
}
}
kou6839