結果

問題 No.2 素因数ゲーム
ユーザー yn
提出日時 2015-10-05 00:40:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-26 11:53:31
合計ジャッジ時間 2,432 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def solve(n, num):
    x = 0
    for i in num:
        if n < i * i:
            break

        cnt = 0
        while n % i == 0:
            n = n // i
            #d.append(i)
            #d_set.add(i)
            cnt += 1
        x ^= cnt

    if n > 1:
        x ^= 1

    if x == 0:
        return False
    else:
        return True

M = 10000
table = [True] * (M + 1)
num = []

for i in range(2, M + 1):
    if not table[i]:
        continue
    k = i + i
    while k < M + 1:
        table[k] = False
        k += i

    num.append(i)

n = int(input())
if solve(n, num):
    print("Alice")
else:
    print("Bob")
0