結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
kuramu
|
| 提出日時 | 2016-01-31 00:03:31 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 2,247 ms / 5,000 ms |
| コード長 | 1,435 bytes |
| コンパイル時間 | 6,128 ms |
| コンパイル使用メモリ | 78,716 KB |
| 実行使用メモリ | 138,352 KB |
| 最終ジャッジ日時 | 2024-12-26 12:19:23 |
| 合計ジャッジ時間 | 36,579 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
BufferedReader stdReader =new BufferedReader(new InputStreamReader(System.in));
try {
int N = Integer.parseInt(stdReader.readLine());
boolean[] dp = new boolean[N+1];
ArrayList<Integer> primeList = new ArrayList<>();
HashMap<Integer , Integer> hashMap = new HashMap<>();
Arrays.fill(dp, true);
dp[0] = false;
dp[1] = false;
for(int i=2;i*i<=N;i++){
if(dp[i]){
for(int j=2;j*i<=N;j++){
dp[i*j] = false;
}
}
}
int index = 2;
while(N>1){
if(dp[index] && N % index == 0){
if(!hashMap.containsKey(index)){
hashMap.put(index, 1);
primeList.add(index);
}else{
hashMap.put(index, hashMap.get(index)+1);
}
N /= index;
}else{
index++;
}
}
int result = 0;
for(int i=0;i<primeList.size();i++){
result ^= hashMap.get(primeList.get(i));
}
System.out.println(result==0?"Bob":"Alice");
} catch (IOException e) {
e.printStackTrace();
}
}
}
kuramu