結果
問題 | No.153 石の山 |
ユーザー |
![]() |
提出日時 | 2015-02-16 21:51:42 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 142 ms / 5,000 ms |
コード長 | 653 bytes |
コンパイル時間 | 2,316 ms |
コンパイル使用メモリ | 80,032 KB |
実行使用メモリ | 41,692 KB |
最終ジャッジ日時 | 2024-10-14 14:30:11 |
合計ジャッジ時間 | 6,275 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 27 |
ソースコード
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"); } }