結果

問題 No.153 石の山
ユーザー ぴろずぴろず
提出日時 2015-02-16 21:51:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 653 bytes
コンパイル時間 2,543 ms
コンパイル使用メモリ 75,388 KB
実行使用メモリ 54,596 KB
最終ジャッジ日時 2024-04-22 15:24:38
合計ジャッジ時間 7,695 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,352 KB
testcase_01 AC 129 ms
54,176 KB
testcase_02 AC 128 ms
54,000 KB
testcase_03 AC 132 ms
53,924 KB
testcase_04 AC 127 ms
54,352 KB
testcase_05 AC 128 ms
54,596 KB
testcase_06 AC 129 ms
54,444 KB
testcase_07 AC 130 ms
53,900 KB
testcase_08 AC 129 ms
54,284 KB
testcase_09 AC 116 ms
54,076 KB
testcase_10 AC 126 ms
54,164 KB
testcase_11 AC 125 ms
54,048 KB
testcase_12 AC 129 ms
54,068 KB
testcase_13 AC 121 ms
52,764 KB
testcase_14 AC 130 ms
54,072 KB
testcase_15 AC 129 ms
54,156 KB
testcase_16 AC 121 ms
52,836 KB
testcase_17 AC 129 ms
54,060 KB
testcase_18 AC 115 ms
52,920 KB
testcase_19 AC 128 ms
53,956 KB
testcase_20 AC 130 ms
54,012 KB
testcase_21 AC 131 ms
54,140 KB
testcase_22 AC 126 ms
54,300 KB
testcase_23 AC 128 ms
54,284 KB
testcase_24 AC 127 ms
53,968 KB
testcase_25 AC 130 ms
54,220 KB
testcase_26 AC 129 ms
54,148 KB
testcase_27 AC 131 ms
53,856 KB
testcase_28 AC 130 ms
54,220 KB
testcase_29 AC 121 ms
52,816 KB
testcase_30 AC 119 ms
52,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no153;

import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int[] grundy = new int[101];
		for(int i=2;i<=100;i++) {
			PriorityQueue<Integer> s = new PriorityQueue<>();
			s.add(grundy[i/2] ^ grundy[(i+1)/2]);
			if (i >= 3) {
				s.add(grundy[i/3] ^ grundy[(i+1)/3] ^ grundy[(i+2)/3]);
			}
			s.add(999);
			for(int j=0;j<3;j++) {
				if (s.poll() != j) {
					grundy[i] = j;
					break;
				}
			}
		}
//		System.out.println(Arrays.toString(grundy));

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		System.out.println(grundy[n] == 0 ? "B" : "A");
	}
}
0