結果

問題 No.2 素因数ゲーム
ユーザー Hydru
提出日時 2023-01-15 12:58:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 869 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 59,328 KB
最終ジャッジ日時 2024-12-28 03:30:55
合計ジャッジ時間 2,744 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())

def factorization(n):
    # nを素因数分解したリストを返す
    arr = []
    tmp = n
    for i in [2,3]:
        if tmp%i==0:
            cnt=0
            while(tmp%i==0):
                cnt+=1
                tmp//=i
            arr.append([i,cnt])
    for i in range(5, int(-(-tmp**0.5//1))+1,2):
        if tmp%i==0:
            cnt=0
            while tmp%i==0:
                cnt+=1
                tmp //= i
            arr.append([i, cnt])

    if tmp!=1:
        arr.append([tmp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

A=factorization(n)

B=[a[1] for a in A]

def Nim(A):
    #山取りゲーム
    #最後の山を取った人が勝ち
    p=0
    for a in A:
        p^=a
    if p==0:
        return 1 #後手
    else:
        return 0 #先手

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