結果

問題 No.153 石の山
ユーザー kou6839kou6839
提出日時 2015-03-28 00:04:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 133 ms / 5,000 ms
コード長 661 bytes
コンパイル時間 2,398 ms
コンパイル使用メモリ 79,236 KB
実行使用メモリ 41,496 KB
最終ジャッジ日時 2024-04-22 15:28:11
合計ジャッジ時間 7,502 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
41,176 KB
testcase_01 AC 132 ms
41,268 KB
testcase_02 AC 132 ms
41,204 KB
testcase_03 AC 131 ms
41,372 KB
testcase_04 AC 132 ms
41,184 KB
testcase_05 AC 133 ms
41,308 KB
testcase_06 AC 128 ms
41,496 KB
testcase_07 AC 132 ms
41,120 KB
testcase_08 AC 132 ms
41,244 KB
testcase_09 AC 132 ms
41,376 KB
testcase_10 AC 123 ms
40,240 KB
testcase_11 AC 129 ms
41,332 KB
testcase_12 AC 132 ms
41,456 KB
testcase_13 AC 130 ms
41,388 KB
testcase_14 AC 129 ms
41,108 KB
testcase_15 AC 129 ms
41,240 KB
testcase_16 AC 116 ms
40,180 KB
testcase_17 AC 129 ms
41,292 KB
testcase_18 AC 129 ms
40,992 KB
testcase_19 AC 119 ms
40,248 KB
testcase_20 AC 116 ms
40,328 KB
testcase_21 AC 131 ms
41,144 KB
testcase_22 AC 128 ms
41,128 KB
testcase_23 AC 131 ms
41,000 KB
testcase_24 AC 123 ms
40,260 KB
testcase_25 AC 130 ms
41,272 KB
testcase_26 AC 126 ms
41,424 KB
testcase_27 AC 117 ms
40,352 KB
testcase_28 AC 128 ms
41,272 KB
testcase_29 AC 116 ms
40,124 KB
testcase_30 AC 116 ms
39,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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");
		}
	}
}
0