結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,272 KB
testcase_01 WA -
testcase_02 AC 45 ms
49,072 KB
testcase_03 AC 44 ms
49,304 KB
testcase_04 WA -
testcase_05 AC 45 ms
49,136 KB
testcase_06 AC 45 ms
49,260 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 45 ms
49,256 KB
testcase_11 WA -
testcase_12 AC 46 ms
49,416 KB
testcase_13 WA -
testcase_14 AC 45 ms
49,288 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 46 ms
49,068 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 46 ms
49,152 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 46 ms
49,200 KB
testcase_28 AC 45 ms
49,240 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++) {
            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