結果

問題 No.2 素因数ゲーム
ユーザー Amanita2016Amanita2016
提出日時 2017-09-14 08:52:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 797 bytes
コンパイル時間 3,666 ms
コンパイル使用メモリ 71,952 KB
実行使用メモリ 49,680 KB
最終ジャッジ日時 2023-08-27 04:47:32
合計ジャッジ時間 5,827 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,232 KB
testcase_01 AC 43 ms
49,144 KB
testcase_02 AC 43 ms
49,252 KB
testcase_03 AC 43 ms
49,244 KB
testcase_04 AC 43 ms
49,168 KB
testcase_05 AC 43 ms
49,228 KB
testcase_06 AC 43 ms
49,304 KB
testcase_07 AC 43 ms
49,172 KB
testcase_08 AC 43 ms
49,240 KB
testcase_09 AC 42 ms
49,320 KB
testcase_10 AC 44 ms
49,332 KB
testcase_11 AC 43 ms
49,312 KB
testcase_12 AC 43 ms
49,452 KB
testcase_13 AC 43 ms
49,388 KB
testcase_14 AC 42 ms
49,680 KB
testcase_15 AC 42 ms
49,592 KB
testcase_16 AC 43 ms
49,340 KB
testcase_17 AC 43 ms
49,272 KB
testcase_18 AC 43 ms
49,232 KB
testcase_19 AC 43 ms
49,232 KB
testcase_20 AC 42 ms
49,228 KB
testcase_21 AC 43 ms
49,420 KB
testcase_22 AC 43 ms
49,256 KB
testcase_23 AC 42 ms
49,248 KB
testcase_24 AC 42 ms
49,096 KB
testcase_25 AC 43 ms
49,428 KB
testcase_26 AC 43 ms
49,284 KB
testcase_27 AC 42 ms
49,256 KB
testcase_28 AC 43 ms
49,268 KB
testcase_29 AC 43 ms
49,092 KB
testcase_30 AC 43 ms
49,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class PrimeFactorsGame {

	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = 0;
		try {
			num = Integer.parseInt(br.readLine());
		}catch (IOException e){}
		double sqr = Math.sqrt(num);
		int xor = 0;
		int cnt = 0;
		while((num & 1) == 0){
			cnt++;
			num /= 2;
		}
		xor ^= cnt;
		for(int i = 3 ; i <= sqr ; i += 2){
			if((num % i) == 0){
				cnt = 0;
				do{
					num /= i;
					cnt++;
				}while((num % i) == 0);
				xor ^= cnt;
			}
		}
		if(num != 1){
			xor ^= 1;
		}
		String disp = (xor == 0) ? "Bob" : "Alice";
		System.out.println(disp);
	}
}
0