結果

問題 No.2 素因数ゲーム
ユーザー jp_stejp_ste
提出日時 2016-03-04 02:32:55
言語 Java19
(openjdk 21)
結果
AC  
実行時間 826 ms / 5,000 ms
コード長 970 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 71,996 KB
実行使用メモリ 449,520 KB
最終ジャッジ日時 2023-08-27 04:26:31
合計ジャッジ時間 15,684 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,068 KB
testcase_01 AC 125 ms
55,752 KB
testcase_02 AC 123 ms
55,516 KB
testcase_03 AC 123 ms
56,068 KB
testcase_04 AC 123 ms
55,812 KB
testcase_05 AC 131 ms
55,732 KB
testcase_06 AC 210 ms
106,292 KB
testcase_07 AC 218 ms
114,192 KB
testcase_08 AC 214 ms
108,192 KB
testcase_09 AC 826 ms
449,520 KB
testcase_10 AC 625 ms
391,796 KB
testcase_11 AC 364 ms
214,800 KB
testcase_12 AC 363 ms
215,340 KB
testcase_13 AC 598 ms
377,576 KB
testcase_14 AC 180 ms
87,724 KB
testcase_15 AC 273 ms
151,392 KB
testcase_16 AC 469 ms
286,852 KB
testcase_17 AC 652 ms
400,136 KB
testcase_18 AC 668 ms
422,540 KB
testcase_19 AC 458 ms
268,436 KB
testcase_20 AC 557 ms
338,892 KB
testcase_21 AC 717 ms
438,752 KB
testcase_22 AC 668 ms
408,508 KB
testcase_23 AC 373 ms
221,344 KB
testcase_24 AC 673 ms
427,032 KB
testcase_25 AC 550 ms
330,184 KB
testcase_26 AC 414 ms
249,680 KB
testcase_27 AC 283 ms
159,684 KB
testcase_28 AC 453 ms
276,912 KB
testcase_29 AC 396 ms
235,620 KB
testcase_30 AC 377 ms
225,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scan = new Scanner(System.in)) {
            int N = scan.nextInt();
            int nums[] = new int[N+1];
            
            int n = N;
            for(int i=2; i<=N; i++) {
                while(n % i == 0) {
                    n /= i;
                    nums[i]++;
                }
            }
            if(n > 1) { 
                nums[n]++;
            }
            
            int ans = 0;
            for(int i=2; i<=N; i++) {
                if(nums[i] > 0) {
                    if(ans == 0) {
                        ans = nums[i];
                    } else {
                        ans ^= nums[i];
                    }
                }
            }
            if(ans != 0) {
                System.out.println("Alice");
            } else {
                System.out.println("Bob");
            }
        }        
    }
}
0