結果

問題 No.2 素因数ゲーム
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-12 23:51:07
言語 Java21
(openjdk 21)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,458 bytes
コンパイル時間 3,706 ms
コンパイル使用メモリ 76,176 KB
実行使用メモリ 545,016 KB
最終ジャッジ日時 2023-09-25 08:33:59
合計ジャッジ時間 20,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,968 KB
testcase_01 AC 129 ms
55,644 KB
testcase_02 AC 126 ms
55,952 KB
testcase_03 AC 126 ms
55,764 KB
testcase_04 AC 124 ms
55,808 KB
testcase_05 AC 147 ms
55,948 KB
testcase_06 AC 218 ms
116,500 KB
testcase_07 AC 219 ms
126,396 KB
testcase_08 AC 222 ms
118,248 KB
testcase_09 MLE -
testcase_10 AC 513 ms
470,324 KB
testcase_11 AC 332 ms
248,768 KB
testcase_12 AC 330 ms
248,300 KB
testcase_13 AC 486 ms
450,976 KB
testcase_14 AC 172 ms
94,088 KB
testcase_15 AC 499 ms
170,184 KB
testcase_16 AC 694 ms
337,828 KB
testcase_17 AC 521 ms
480,212 KB
testcase_18 MLE -
testcase_19 AC 1,173 ms
316,856 KB
testcase_20 AC 933 ms
405,016 KB
testcase_21 MLE -
testcase_22 AC 535 ms
490,836 KB
testcase_23 AC 349 ms
257,220 KB
testcase_24 MLE -
testcase_25 AC 477 ms
394,052 KB
testcase_26 AC 381 ms
292,736 KB
testcase_27 AC 267 ms
180,884 KB
testcase_28 AC 416 ms
324,752 KB
testcase_29 AC 372 ms
276,288 KB
testcase_30 AC 885 ms
261,400 KB
権限があれば一括ダウンロードができます

ソースコード

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