結果

問題 No.2 素因数ゲーム
ユーザー kuramukuramu
提出日時 2016-01-30 23:50:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,823 bytes
コンパイル時間 2,253 ms
コンパイル使用メモリ 78,536 KB
実行使用メモリ 155,576 KB
最終ジャッジ日時 2023-10-21 18:16:02
合計ジャッジ時間 26,612 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
53,432 KB
testcase_01 AC 53 ms
53,440 KB
testcase_02 AC 54 ms
52,332 KB
testcase_03 AC 55 ms
53,376 KB
testcase_04 AC 54 ms
53,436 KB
testcase_05 WA -
testcase_06 AC 191 ms
71,468 KB
testcase_07 WA -
testcase_08 AC 225 ms
71,476 KB
testcase_09 AC 1,602 ms
155,576 KB
testcase_10 AC 1,365 ms
141,212 KB
testcase_11 WA -
testcase_12 AC 636 ms
98,096 KB
testcase_13 WA -
testcase_14 AC 155 ms
62,660 KB
testcase_15 AC 385 ms
81,728 KB
testcase_16 WA -
testcase_17 AC 1,383 ms
143,264 KB
testcase_18 AC 1,503 ms
149,452 KB
testcase_19 AC 963 ms
110,404 KB
testcase_20 AC 1,202 ms
128,900 KB
testcase_21 AC 1,681 ms
153,496 KB
testcase_22 WA -
testcase_23 AC 672 ms
100,048 KB
testcase_24 AC 1,507 ms
149,316 KB
testcase_25 WA -
testcase_26 AC 780 ms
106,300 KB
testcase_27 AC 371 ms
84,024 KB
testcase_28 WA -
testcase_29 AC 700 ms
102,200 KB
testcase_30 AC 686 ms
100,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 mult = 0;
	    	  for(int i=0;i<primeList.size();i++){
	    		  if(hashMap.get(primeList.get(i))>1) mult++;
	    	  }
	    	  if(primeList.size()==1){
	    		  System.out.println("Alice");
	    		  return;
	    	  }
	    	  
	    	  if(primeList.size() % 2 == 0){
	    		  if(mult % 2 == 0){
	    			  System.out.println("Bob");
	    		  }else{
	    			  System.out.println("Alice");
	    		  }
	    	  }else{
	    		  if(mult % 2 == 0){
	    			  	System.out.println("Bob");
	    		  }else{
	    			  	System.out.println("Alice");
	    		  }
	    	  }
	    	  
	      } catch (IOException e) {
			e.printStackTrace();
	      }
	}
}
0