結果

問題 No.2 素因数ゲーム
ユーザー mastersatoshimastersatoshi
提出日時 2015-07-29 23:23:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 986 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 73,084 KB
実行使用メモリ 50,616 KB
最終ジャッジ日時 2023-09-24 22:05:48
合計ジャッジ時間 5,951 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,324 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 45 ms
49,140 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 45 ms
49,200 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 46 ms
49,328 KB
testcase_11 AC 47 ms
49,280 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 54 ms
50,108 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 71 ms
50,020 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 45 ms
49,132 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        long N = Long.parseLong(br.readLine());

        long max = (long) Math.sqrt(N);

        HashMap<Long, Integer> pNumber = new HashMap();

        for (long i = 2; i <= N / 2; i++) {
            if (N % i == 0) {
                N = N / i;

                if (pNumber.containsKey(i)) {
                    if (pNumber.get(i) == 1) {
                        pNumber.remove(i, 2);
                    }
                } else {
                    pNumber.put(i, 1);
                }
            }
        }

        int cons = 0;

        for (long a : pNumber.keySet()) {
            cons = cons + pNumber.get(a);
        }

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