結果

問題 No.2 素因数ゲーム
ユーザー GrenacheGrenache
提出日時 2016-03-05 10:34:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 1,065 bytes
コンパイル時間 3,513 ms
コンパイル使用メモリ 75,392 KB
実行使用メモリ 56,516 KB
最終ジャッジ日時 2023-08-27 04:24:37
合計ジャッジ時間 8,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,812 KB
testcase_01 AC 124 ms
56,212 KB
testcase_02 AC 124 ms
56,040 KB
testcase_03 AC 125 ms
55,988 KB
testcase_04 AC 125 ms
56,344 KB
testcase_05 AC 125 ms
55,864 KB
testcase_06 AC 124 ms
56,120 KB
testcase_07 AC 123 ms
56,032 KB
testcase_08 AC 122 ms
56,336 KB
testcase_09 AC 123 ms
56,336 KB
testcase_10 AC 123 ms
56,160 KB
testcase_11 AC 125 ms
55,556 KB
testcase_12 AC 127 ms
56,044 KB
testcase_13 AC 126 ms
56,172 KB
testcase_14 AC 125 ms
55,908 KB
testcase_15 AC 127 ms
56,516 KB
testcase_16 AC 126 ms
55,812 KB
testcase_17 AC 127 ms
55,948 KB
testcase_18 AC 125 ms
56,100 KB
testcase_19 AC 124 ms
56,240 KB
testcase_20 AC 123 ms
55,840 KB
testcase_21 AC 125 ms
56,288 KB
testcase_22 AC 125 ms
55,564 KB
testcase_23 AC 123 ms
56,108 KB
testcase_24 AC 123 ms
56,128 KB
testcase_25 AC 125 ms
56,140 KB
testcase_26 AC 125 ms
56,024 KB
testcase_27 AC 123 ms
56,304 KB
testcase_28 AC 123 ms
56,348 KB
testcase_29 AC 125 ms
56,188 KB
testcase_30 AC 126 ms
55,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main_yukicoder2 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        Map<Integer, Integer> pf = primeFactorization(n);

        int ret = 0;
        for (int e : pf.values()) {
        	ret ^= e;
        }

        if (ret == 0) {
        	System.out.println("Bob");
        } else {
        	System.out.println("Alice");
        }

        sc.close();
    }

    private static Map<Integer, Integer> primeFactorization(int n) {
    	Map<Integer, Integer> hm = new HashMap<Integer, Integer>();

    	int tmp = n;
    	for (int j = 2; j * j <= n; j++) {
    		while (tmp % j == 0) {
    			if (hm.containsKey(j)) {
    				hm.put(j, hm.get(j) + 1);
    			} else {
    				hm.put(j, 1);
    			}
    			tmp /= j;
    		}
    	}
    	if (tmp != 1) {
    		if (hm.containsKey(tmp)) {
    			hm.put(tmp, hm.get(tmp) + 1);
    		} else {
    			hm.put(tmp, 1);
    		}
    	}

    	return hm;
    }
}
0