結果

問題 No.2 素因数ゲーム
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-08-12 18:54:01
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,203 bytes
コンパイル時間 3,797 ms
コンパイル使用メモリ 76,004 KB
実行使用メモリ 553,664 KB
最終ジャッジ日時 2023-09-25 08:30:57
合計ジャッジ時間 38,238 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
55,552 KB
testcase_01 AC 114 ms
55,808 KB
testcase_02 AC 114 ms
55,676 KB
testcase_03 AC 118 ms
55,620 KB
testcase_04 AC 117 ms
56,012 KB
testcase_05 AC 140 ms
56,076 KB
testcase_06 AC 253 ms
118,244 KB
testcase_07 AC 270 ms
128,732 KB
testcase_08 AC 270 ms
122,672 KB
testcase_09 RE -
testcase_10 AC 2,131 ms
490,464 KB
testcase_11 AC 902 ms
259,732 KB
testcase_12 AC 881 ms
260,020 KB
testcase_13 AC 1,995 ms
472,180 KB
testcase_14 AC 205 ms
93,916 KB
testcase_15 AC 498 ms
175,328 KB
testcase_16 AC 1,430 ms
352,372 KB
testcase_17 AC 2,215 ms
502,224 KB
testcase_18 MLE -
testcase_19 AC 1,365 ms
331,608 KB
testcase_20 AC 1,769 ms
424,236 KB
testcase_21 MLE -
testcase_22 MLE -
testcase_23 AC 1,055 ms
270,076 KB
testcase_24 MLE -
testcase_25 AC 1,744 ms
412,236 KB
testcase_26 AC 1,192 ms
304,928 KB
testcase_27 AC 547 ms
187,552 KB
testcase_28 AC 1,430 ms
341,964 KB
testcase_29 AC 1,125 ms
288,708 KB
testcase_30 AC 1,052 ms
274,380 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 x = 0;
		int[] primes = sieveOfEratosthenes(n+1);
		int ptr = 0;
		while (n != 1) {
			int cnt = 0;
			while (n%primes[ptr] == 0) {
				n /= primes[ptr];
				cnt++;
			}
			x ^= cnt;
			ptr++;
		}

		out.println(x != 0 ? "Alice" : "Bob");
	}

	static int[] sieveOfEratosthenes(int n) {
		if (n < 2) return null;
		boolean[] isPrime = new boolean[n];
		Arrays.fill(isPrime,true);
		int[] res = new int[n];
		int ptr = 0;
		isPrime[0] = isPrime[1] = false;
		for (int i=2; i<n; i++) {
			if (isPrime[i]) {
				res[ptr++] = i;
				for (int j=i+i; j<n; j+=i) isPrime[j] = false;
			}
		}
		return Arrays.copyOfRange(res,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