結果

問題 No.2 素因数ゲーム
ユーザー mastersatoshimastersatoshi
提出日時 2015-07-29 23:25:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,117 bytes
コンパイル時間 3,230 ms
コンパイル使用メモリ 72,104 KB
実行使用メモリ 49,784 KB
最終ジャッジ日時 2023-09-24 22:06:41
合計ジャッジ時間 5,810 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,192 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 43 ms
49,504 KB
testcase_06 AC 42 ms
49,288 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 43 ms
49,284 KB
testcase_10 WA -
testcase_11 AC 43 ms
49,264 KB
testcase_12 AC 43 ms
49,252 KB
testcase_13 AC 43 ms
49,600 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 43 ms
49,256 KB
testcase_28 AC 44 ms
49,424 KB
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 <= max; i++) {
            while (true) {
                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);
                    }
                } else {
                    break;
                }
            }
        }

        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