結果

問題 No.2 素因数ゲーム
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-13 02:55:54
言語 Java21
(openjdk 21)
結果
MLE  
実行時間 -
コード長 1,677 bytes
コンパイル時間 5,786 ms
コンパイル使用メモリ 78,396 KB
実行使用メモリ 719,732 KB
最終ジャッジ日時 2023-09-25 11:22:14
合計ジャッジ時間 16,238 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,464 KB
testcase_01 AC 129 ms
55,712 KB
testcase_02 AC 124 ms
55,464 KB
testcase_03 AC 126 ms
55,748 KB
testcase_04 AC 126 ms
55,904 KB
testcase_05 AC 149 ms
56,468 KB
testcase_06 AC 922 ms
160,580 KB
testcase_07 AC 711 ms
143,672 KB
testcase_08 AC 817 ms
158,228 KB
testcase_09 MLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

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();
		ArrayList<int[]> f = requirePrimeFactor(n);
		//trace(f.toArray());
		int x = 0;
		for (int[] y : f) {
			x ^= y[1];
		}
		out.println(x != 0 ? "Alice" : "Bob");
	}

	public static ArrayList<int[]> requirePrimeFactor(int n) {
		if (n < 2) return null;
		ArrayList<int[]> ret = new ArrayList<int[]>();
		ArrayList<Integer> primes = createPrimeList(0,n+1);
		for (int p : primes) {
			int exp = 0;
			while (n%p == 0) {
				n /= p;
				exp++;
			}
			if (exp > 0) ret.add(new int[]{p,exp});
		}
		if (n > 1) ret.add(new int[]{n,1});
		return ret;
	}

	public static ArrayList<Integer> createPrimeList(int offset, int n) {
		if (n < 2) return null;
		ArrayList<Integer> ret = new ArrayList<Integer>();
		BitSet isPrimeBit = createIsPrimeBit(offset,n);
		int p = 1;
		while ((p = isPrimeBit.nextSetBit(p+1)) >= 0) {
			ret.add(p);
		}
		return ret;
	}

	public static BitSet createIsPrimeBit(int offset, int n) {
		if (n < 2) return null;
		BitSet ret = new BitSet();
		ret.flip(2,n);
		for (int i=2; i*i<n; i++) {
			if (!ret.get(i)) continue;
			for (int j=i+i; j<n; j+=i) ret.flip(j);
		}
		return ret;
	}

	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