結果

問題 No.2 素因数ゲーム
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-12 23:50:04
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,456 bytes
コンパイル時間 4,138 ms
コンパイル使用メモリ 78,884 KB
実行使用メモリ 543,808 KB
最終ジャッジ日時 2023-09-25 08:34:26
合計ジャッジ時間 21,925 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 MLE -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 MLE -
testcase_19 WA -
testcase_20 WA -
testcase_21 MLE -
testcase_22 WA -
testcase_23 WA -
testcase_24 MLE -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class No0002 {
    
    static final Scanner in = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);

    static void solve() {
        int n = in.nextInt();
        int[][] f = requirePrimeFactor(n);
        int x = 0;
        for (int[] y : f) {
            x ^= y[1];
        }
        out.println(x != 0 ? "Alice" : "Bob");
    }

    static int[][] requirePrimeFactor(int n) {
        if (n < 2) return null;
        int[][] ret = new int[n+1][];
        boolean[] isPrime = new boolean[n+1];
        Arrays.fill(isPrime,true);

        int ptr = 0;
        for (int i=2; i*i<=n; i++) {
            if (!isPrime[i]) continue;
            for (int j=i*2; j<=n; j+=i) isPrime[j] = false;

            int exp = 0;
            while (n%i == 0) {
                n /= i;
                exp++;
            }
            if (exp > 0) ret[ptr++] = new int[]{i,exp};
        }

        if (n > 1) ret[ptr++] = new int[]{n,1};

        return Arrays.copyOfRange(ret,0,ptr);
    }

    public static void main(String[] args) {
        long start = System.currentTimeMillis();

        solve();
        out.flush();

        long end = System.currentTimeMillis();
        trace(end-start + "ms");
        in.close();
        out.close();
    }

    static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}
0