結果

問題 No.2 素因数ゲーム
ユーザー kyawashell
提出日時 2017-12-08 11:53:52
言語 Java
(openjdk 23)
結果
AC  
実行時間 3,089 ms / 5,000 ms
コード長 955 bytes
コンパイル時間 4,211 ms
コンパイル使用メモリ 77,828 KB
実行使用メモリ 340,568 KB
最終ジャッジ日時 2024-12-26 13:27:09
合計ジャッジ時間 50,622 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

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