結果

問題 No.2 素因数ゲーム
ユーザー kyawashellkyawashell
提出日時 2017-12-08 11:53:52
言語 Java19
(openjdk 21)
結果
AC  
実行時間 2,478 ms / 5,000 ms
コード長 955 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 74,832 KB
実行使用メモリ 349,820 KB
最終ジャッジ日時 2023-08-27 04:52:49
合計ジャッジ時間 37,992 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,088 KB
testcase_01 AC 124 ms
55,504 KB
testcase_02 AC 125 ms
55,816 KB
testcase_03 AC 127 ms
55,912 KB
testcase_04 AC 125 ms
56,044 KB
testcase_05 AC 150 ms
56,052 KB
testcase_06 AC 320 ms
87,524 KB
testcase_07 AC 342 ms
95,536 KB
testcase_08 AC 318 ms
92,004 KB
testcase_09 AC 2,478 ms
349,820 KB
testcase_10 AC 2,052 ms
316,536 KB
testcase_11 AC 908 ms
167,248 KB
testcase_12 AC 906 ms
166,660 KB
testcase_13 AC 1,945 ms
298,128 KB
testcase_14 AC 244 ms
75,240 KB
testcase_15 AC 526 ms
126,988 KB
testcase_16 AC 1,463 ms
240,244 KB
testcase_17 AC 2,071 ms
321,364 KB
testcase_18 AC 2,262 ms
337,940 KB
testcase_19 AC 1,339 ms
230,856 KB
testcase_20 AC 1,797 ms
282,780 KB
testcase_21 AC 2,343 ms
347,428 KB
testcase_22 AC 2,144 ms
326,756 KB
testcase_23 AC 921 ms
170,680 KB
testcase_24 AC 2,239 ms
336,936 KB
testcase_25 AC 1,485 ms
231,040 KB
testcase_26 AC 1,228 ms
208,888 KB
testcase_27 AC 567 ms
126,732 KB
testcase_28 AC 1,422 ms
234,516 KB
testcase_29 AC 1,182 ms
204,984 KB
testcase_30 AC 949 ms
173,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main{
	static void gethurui(boolean hurui[],int n){
		hurui[0] = hurui[1] = false;
		for(int i = 2;i <= n;i++)
			hurui[i] = true;
		for(int i = 2;i <= (int)(Math.sqrt(n) + 0.1);i++){
			if(!hurui[i])
				continue;
			for(int j = i * 2;j <= n;j += i){
				hurui[j] = false;
			}
		}
	}
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		scan.close();
		boolean[] hurui = new boolean[n + 1];
		gethurui(hurui,n);

		ArrayList<Integer> ps = new ArrayList<Integer>();

		for(int i = 0;i <= n;i++){
			if(hurui[i])
				ps.add(i);
		}

		ArrayList<Integer> ms = new ArrayList<Integer>();

		int n2 = n;
		for(Integer p : ps){
			int c = 0;
			while(n % p == 0){
				c++;
				n /= p;
			}
			if(c > 0)
				ms.add(c);
		}

		int ans = 0;
		for(Integer m : ms){
			ans = (ans ^ m);
		}

		if(ans != 0)
			System.out.println("Alice");
		else
			System.out.println("Bob");
	}
}
0