結果

問題 No.2 素因数ゲーム
ユーザー tenten
提出日時 2020-11-26 14:45:40
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 587 bytes
コンパイル時間 3,507 ms
コンパイル使用メモリ 75,840 KB
実行使用メモリ 54,208 KB
最終ジャッジ日時 2024-07-23 20:49:31
合計ジャッジ時間 7,991 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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