結果

問題 No.153 石の山
ユーザー ぴろずぴろず
提出日時 2015-02-16 21:51:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 653 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 73,696 KB
実行使用メモリ 55,840 KB
最終ジャッジ日時 2023-08-04 17:19:22
合計ジャッジ時間 6,979 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,416 KB
testcase_01 AC 118 ms
55,424 KB
testcase_02 AC 128 ms
55,536 KB
testcase_03 AC 119 ms
55,488 KB
testcase_04 AC 119 ms
55,664 KB
testcase_05 AC 121 ms
55,420 KB
testcase_06 AC 122 ms
55,592 KB
testcase_07 AC 121 ms
55,540 KB
testcase_08 AC 119 ms
55,468 KB
testcase_09 AC 118 ms
55,488 KB
testcase_10 AC 118 ms
55,416 KB
testcase_11 AC 117 ms
55,428 KB
testcase_12 AC 117 ms
55,616 KB
testcase_13 AC 119 ms
55,800 KB
testcase_14 AC 121 ms
55,768 KB
testcase_15 AC 119 ms
55,484 KB
testcase_16 AC 122 ms
55,292 KB
testcase_17 AC 125 ms
55,452 KB
testcase_18 AC 119 ms
55,552 KB
testcase_19 AC 117 ms
55,624 KB
testcase_20 AC 118 ms
55,840 KB
testcase_21 AC 118 ms
55,772 KB
testcase_22 AC 115 ms
55,692 KB
testcase_23 AC 118 ms
55,472 KB
testcase_24 AC 120 ms
55,536 KB
testcase_25 AC 120 ms
55,568 KB
testcase_26 AC 117 ms
55,536 KB
testcase_27 AC 123 ms
55,728 KB
testcase_28 AC 121 ms
55,584 KB
testcase_29 AC 117 ms
55,644 KB
testcase_30 AC 118 ms
55,456 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