結果

問題 No.1665 quotient replace
ユーザー shiroha_F14shiroha_F14
提出日時 2021-08-11 20:26:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,334 ms / 3,000 ms
コード長 801 bytes
コンパイル時間 4,285 ms
コンパイル使用メモリ 74,236 KB
実行使用メモリ 75,516 KB
最終ジャッジ日時 2023-08-21 18:55:02
合計ジャッジ時間 31,546 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
60,328 KB
testcase_01 AC 152 ms
60,212 KB
testcase_02 AC 151 ms
58,556 KB
testcase_03 AC 214 ms
60,840 KB
testcase_04 AC 205 ms
60,584 KB
testcase_05 AC 154 ms
59,720 KB
testcase_06 AC 246 ms
63,588 KB
testcase_07 AC 217 ms
61,064 KB
testcase_08 AC 238 ms
63,152 KB
testcase_09 AC 337 ms
64,628 KB
testcase_10 AC 810 ms
72,092 KB
testcase_11 AC 1,154 ms
75,236 KB
testcase_12 AC 526 ms
64,956 KB
testcase_13 AC 1,119 ms
75,516 KB
testcase_14 AC 1,086 ms
74,644 KB
testcase_15 AC 1,095 ms
73,772 KB
testcase_16 AC 1,106 ms
74,108 KB
testcase_17 AC 1,334 ms
74,876 KB
testcase_18 AC 148 ms
60,396 KB
testcase_19 AC 149 ms
60,616 KB
testcase_20 AC 149 ms
60,392 KB
testcase_21 AC 149 ms
60,096 KB
testcase_22 AC 147 ms
60,272 KB
testcase_23 AC 148 ms
60,184 KB
testcase_24 AC 148 ms
60,128 KB
testcase_25 AC 150 ms
60,048 KB
testcase_26 AC 217 ms
60,796 KB
testcase_27 AC 244 ms
63,456 KB
testcase_28 AC 362 ms
64,988 KB
testcase_29 AC 402 ms
64,960 KB
testcase_30 AC 877 ms
74,524 KB
testcase_31 AC 920 ms
73,340 KB
testcase_32 AC 967 ms
74,096 KB
testcase_33 AC 837 ms
74,020 KB
testcase_34 AC 922 ms
73,040 KB
testcase_35 AC 925 ms
73,284 KB
testcase_36 AC 896 ms
74,560 KB
testcase_37 AC 867 ms
73,196 KB
testcase_38 AC 978 ms
72,524 KB
testcase_39 AC 1,005 ms
75,068 KB
testcase_40 AC 879 ms
74,984 KB
testcase_41 AC 895 ms
74,888 KB
testcase_42 AC 150 ms
60,512 KB
testcase_43 AC 149 ms
60,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    for(int i = 0; i < n; i++) a[i] = Integer.parseInt(sc.next());

    int[] spl = new int[1000001];
    spl[1] = 1;
    for(int i = 2; i <= 1000000; i++){
      if(spl[i] != 0) continue;
      for(int j = i; j <= 1000000; j += i){
        spl[j] = i;
      }
    }

    int[] grundy = new int[n];
    for(int i = 0; i < n; i++){
      while(a[i] > 1){
        a[i] /= spl[a[i]];
        grundy[i]++;
      }
    }

    int nimber = 0;
    for(int i = 0; i < n; i++){
      nimber = nimber ^ grundy[i];
    }
    if(nimber == 0) System.out.println("black");
    else System.out.println("white");
    sc.close();
  }
}
0