結果

問題 No.103 素因数ゲーム リターンズ
ユーザー mattsugu_codermattsugu_coder
提出日時 2022-10-30 22:32:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,117 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 86,908 KB
実行使用メモリ 75,500 KB
最終ジャッジ日時 2023-09-21 20:24:28
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,200 KB
testcase_01 AC 72 ms
70,992 KB
testcase_02 AC 70 ms
71,124 KB
testcase_03 AC 74 ms
71,180 KB
testcase_04 AC 71 ms
71,096 KB
testcase_05 WA -
testcase_06 AC 70 ms
70,992 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 70 ms
70,824 KB
testcase_10 AC 69 ms
71,216 KB
testcase_11 WA -
testcase_12 AC 78 ms
75,324 KB
testcase_13 AC 73 ms
75,100 KB
testcase_14 AC 76 ms
75,500 KB
testcase_15 AC 75 ms
74,948 KB
testcase_16 AC 70 ms
70,988 KB
testcase_17 AC 74 ms
75,168 KB
testcase_18 AC 78 ms
75,300 KB
testcase_19 AC 78 ms
75,212 KB
testcase_20 AC 75 ms
75,360 KB
testcase_21 AC 80 ms
75,248 KB
testcase_22 AC 78 ms
75,168 KB
testcase_23 AC 78 ms
74,948 KB
testcase_24 AC 78 ms
75,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# https://yukicoder.me/problems/no/103
# 素因数ゲームリターンズ
def prime_factorize(X):
    prime_count = []
    N = X
    for i in range(2, N):
        if i*i>X:
            break
        if N % i != 0:
            continue
        cnt = 0
        while N%i == 0:
            N //= i
            cnt += 1
        prime_count.append((i, cnt))
    
    Cnt_list = []
    for i, cnt in prime_count:
        Cnt_list.append(cnt)
    return Cnt_list

N = int(input())
M = list(map(int, input().split()))

# Miのj個目素因数についてgrundy数を求めて、j個のXORを取る。それがMiのgrundy数なのでN個のXORを取る。
# 国の数⇒N, 各国の山の数⇒Mi素因数の数、各山の石の数⇒素因数の肩の数
G = [None]*N
for i in range(N):
    Cnt_list = prime_factorize(M[i])
    nim = 0
    # 今回の場合、各素因数(石の数=素因数の肩の数)のgrundy数は肩の数を3で割った余りと等しい。
    for c in Cnt_list:
        nim ^= (c%3)
    G[i] = nim

Nim = 0
for g in G:
    Nim ^= g

if Nim == 0:
    print("Bob")
else:
    print("Alice")
0