結果

問題 No.2 素因数ゲーム
ユーザー tentententen
提出日時 2020-11-26 14:45:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 72,336 KB
実行使用メモリ 56,676 KB
最終ジャッジ日時 2023-10-01 03:21:34
合計ジャッジ時間 7,771 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,008 KB
testcase_01 AC 113 ms
56,676 KB
testcase_02 AC 115 ms
55,960 KB
testcase_03 AC 112 ms
56,104 KB
testcase_04 AC 112 ms
56,392 KB
testcase_05 AC 112 ms
56,208 KB
testcase_06 AC 114 ms
55,980 KB
testcase_07 AC 122 ms
55,776 KB
testcase_08 AC 114 ms
55,432 KB
testcase_09 AC 118 ms
55,496 KB
testcase_10 AC 123 ms
55,924 KB
testcase_11 AC 116 ms
55,660 KB
testcase_12 AC 115 ms
55,844 KB
testcase_13 AC 115 ms
56,000 KB
testcase_14 AC 117 ms
56,012 KB
testcase_15 AC 117 ms
55,860 KB
testcase_16 AC 117 ms
55,892 KB
testcase_17 AC 117 ms
55,700 KB
testcase_18 AC 114 ms
56,040 KB
testcase_19 AC 120 ms
55,892 KB
testcase_20 AC 118 ms
55,760 KB
testcase_21 AC 117 ms
55,872 KB
testcase_22 AC 121 ms
55,724 KB
testcase_23 AC 116 ms
55,520 KB
testcase_24 AC 117 ms
56,180 KB
testcase_25 AC 116 ms
55,972 KB
testcase_26 AC 114 ms
55,744 KB
testcase_27 AC 116 ms
56,312 KB
testcase_28 AC 115 ms
55,864 KB
testcase_29 AC 118 ms
53,800 KB
testcase_30 AC 117 ms
56,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		for (int i = 2; i <= Math.sqrt(n); i++) {
		    while (n % i == 0) {
		        map.put(i, map.getOrDefault(i, 0) + 1);
		        n /= i;
		    }
		}
		if (n > 1) {
		    map.put(n, map.getOrDefault(n, 0) + 1);
		}
		int ans = 0;
		for (int x : map.values()) {
		    ans ^= x;
		}
		if (ans == 0) {
		    System.out.println("Bob");
		} else {
		    System.out.println("Alice");
		}
	}
}

0