結果

問題 No.2 素因数ゲーム
ユーザー kuramukuramu
提出日時 2016-01-31 00:03:31
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,633 ms / 5,000 ms
コード長 1,435 bytes
コンパイル時間 2,881 ms
コンパイル使用メモリ 76,312 KB
実行使用メモリ 153,328 KB
最終ジャッジ日時 2023-08-27 04:23:45
合計ジャッジ時間 25,422 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
49,156 KB
testcase_01 AC 42 ms
49,164 KB
testcase_02 AC 43 ms
49,184 KB
testcase_03 AC 41 ms
49,360 KB
testcase_04 AC 42 ms
49,332 KB
testcase_05 AC 51 ms
50,516 KB
testcase_06 AC 166 ms
69,168 KB
testcase_07 AC 186 ms
69,192 KB
testcase_08 AC 174 ms
69,516 KB
testcase_09 AC 1,543 ms
153,328 KB
testcase_10 AC 1,281 ms
138,624 KB
testcase_11 AC 595 ms
95,688 KB
testcase_12 AC 587 ms
95,576 KB
testcase_13 AC 1,253 ms
134,648 KB
testcase_14 AC 136 ms
59,600 KB
testcase_15 AC 315 ms
79,244 KB
testcase_16 AC 893 ms
112,340 KB
testcase_17 AC 1,338 ms
140,976 KB
testcase_18 AC 1,428 ms
147,148 KB
testcase_19 AC 905 ms
108,072 KB
testcase_20 AC 1,129 ms
126,584 KB
testcase_21 AC 1,633 ms
151,540 KB
testcase_22 AC 1,368 ms
143,364 KB
testcase_23 AC 616 ms
95,848 KB
testcase_24 AC 1,435 ms
147,188 KB
testcase_25 AC 1,059 ms
124,676 KB
testcase_26 AC 747 ms
104,076 KB
testcase_27 AC 350 ms
81,492 KB
testcase_28 AC 841 ms
110,132 KB
testcase_29 AC 690 ms
99,668 KB
testcase_30 AC 645 ms
95,988 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 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();
	      }
	}
}
0