結果
| 問題 | No.2 素因数ゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-20 15:09:00 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 48 ms / 5,000 ms |
| コード長 | 822 bytes |
| コンパイル時間 | 334 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 57,984 KB |
| 最終ジャッジ日時 | 2024-11-23 19:40:11 |
| 合計ジャッジ時間 | 3,239 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 31 |
ソースコード
import sys
import itertools
input = sys.stdin.readline
def main():
N = int(input())
memo = {1: False}
def check(x, i):
while x % i == 0:
x //= i
if not solve(x):
return True
return False
def solve(x):
if x in memo:
return memo[x]
y = x
for i in itertools.count(2):
if i*i > y:
break
if y % i == 0:
if check(x, i):
memo[x] = True
return True
while y % i == 0:
y //= i
if y != 1 and check(x, y):
memo[x] = True
return True
memo[x] = False
return False
print('Alice' if solve(N) else 'Bob')
if __name__ == '__main__':
main()