結果

問題 No.2 素因数ゲーム
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-13 02:57:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 1,699 bytes
コンパイル時間 4,408 ms
コンパイル使用メモリ 79,872 KB
実行使用メモリ 56,108 KB
最終ジャッジ日時 2023-08-27 04:06:47
合計ジャッジ時間 10,259 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,972 KB
testcase_01 AC 130 ms
55,524 KB
testcase_02 AC 132 ms
55,812 KB
testcase_03 AC 129 ms
55,560 KB
testcase_04 AC 128 ms
55,784 KB
testcase_05 AC 131 ms
55,668 KB
testcase_06 AC 136 ms
55,924 KB
testcase_07 AC 136 ms
55,596 KB
testcase_08 AC 138 ms
55,740 KB
testcase_09 AC 138 ms
56,060 KB
testcase_10 AC 137 ms
55,564 KB
testcase_11 AC 139 ms
55,804 KB
testcase_12 AC 135 ms
55,560 KB
testcase_13 AC 136 ms
55,516 KB
testcase_14 AC 136 ms
55,800 KB
testcase_15 AC 135 ms
55,744 KB
testcase_16 AC 139 ms
55,884 KB
testcase_17 AC 137 ms
55,876 KB
testcase_18 AC 136 ms
55,816 KB
testcase_19 AC 135 ms
55,676 KB
testcase_20 AC 137 ms
55,792 KB
testcase_21 AC 138 ms
56,108 KB
testcase_22 AC 137 ms
55,744 KB
testcase_23 AC 137 ms
55,840 KB
testcase_24 AC 137 ms
55,804 KB
testcase_25 AC 136 ms
56,084 KB
testcase_26 AC 136 ms
55,784 KB
testcase_27 AC 138 ms
55,828 KB
testcase_28 AC 136 ms
55,476 KB
testcase_29 AC 136 ms
55,736 KB
testcase_30 AC 138 ms
55,900 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();
		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,(int)(Math.sqrt(n)+0.5));
		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