結果

問題 No.2 素因数ゲーム
ユーザー takeya_okinotakeya_okino
提出日時 2017-07-11 20:07:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 897 bytes
コンパイル時間 4,177 ms
コンパイル使用メモリ 74,876 KB
実行使用メモリ 56,292 KB
最終ジャッジ日時 2023-08-27 04:45:27
合計ジャッジ時間 7,996 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,756 KB
testcase_01 AC 122 ms
56,012 KB
testcase_02 AC 123 ms
56,036 KB
testcase_03 AC 124 ms
56,000 KB
testcase_04 AC 123 ms
56,068 KB
testcase_05 AC 124 ms
55,756 KB
testcase_06 AC 123 ms
56,032 KB
testcase_07 AC 122 ms
55,900 KB
testcase_08 AC 126 ms
55,976 KB
testcase_09 AC 136 ms
56,072 KB
testcase_10 AC 134 ms
56,052 KB
testcase_11 AC 128 ms
54,232 KB
testcase_12 AC 129 ms
55,612 KB
testcase_13 AC 138 ms
55,924 KB
testcase_14 AC 128 ms
56,124 KB
testcase_15 AC 124 ms
55,988 KB
testcase_16 AC 129 ms
55,996 KB
testcase_17 AC 137 ms
56,104 KB
testcase_18 AC 137 ms
55,832 KB
testcase_19 AC 127 ms
55,716 KB
testcase_20 AC 127 ms
56,032 KB
testcase_21 AC 135 ms
56,020 KB
testcase_22 AC 138 ms
55,796 KB
testcase_23 AC 128 ms
55,804 KB
testcase_24 AC 137 ms
56,292 KB
testcase_25 AC 130 ms
55,908 KB
testcase_26 AC 129 ms
56,196 KB
testcase_27 AC 125 ms
55,888 KB
testcase_28 AC 128 ms
56,056 KB
testcase_29 AC 126 ms
56,100 KB
testcase_30 AC 126 ms
54,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i = 2; i * i <= N; i++) {
      boolean flg = true;
      for(int j = 2; j * j <= i; j++) {
        if(i % j == 0) {
          flg = false;
          break;
        }
      }
      if(flg) list.add(i);
    }
    HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
    for(int i = 0; i < list.size(); i++) {
      int p = list.get(i);
      int count = 0;
      while(N % p == 0) {
        count++;
        N /= p;
      }
      if(count > 0) map.put(p, count);
    }
    if(N > 1) map.put(N, 1);
    int x = 0;
    for(int p : map.keySet()) {
      x = (x ^ map.get(p));
    }
    String ans = "Alice";
    if(x == 0) ans = "Bob";
    System.out.println(ans);
  }
}
0