結果

問題 No.103 素因数ゲーム リターンズ
ユーザー marroncastlemarroncastle
提出日時 2020-09-19 01:34:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 5,000 ms
コード長 434 bytes
コンパイル時間 1,524 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 77,548 KB
最終ジャッジ日時 2023-09-04 17:58:43
合計ジャッジ時間 4,534 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,824 KB
testcase_01 AC 90 ms
71,440 KB
testcase_02 AC 91 ms
71,612 KB
testcase_03 AC 93 ms
71,792 KB
testcase_04 AC 93 ms
71,848 KB
testcase_05 AC 92 ms
71,852 KB
testcase_06 AC 95 ms
71,848 KB
testcase_07 AC 91 ms
71,652 KB
testcase_08 AC 92 ms
71,608 KB
testcase_09 AC 92 ms
71,856 KB
testcase_10 AC 91 ms
71,576 KB
testcase_11 AC 92 ms
71,260 KB
testcase_12 AC 94 ms
71,584 KB
testcase_13 AC 101 ms
77,548 KB
testcase_14 AC 98 ms
76,500 KB
testcase_15 AC 98 ms
76,540 KB
testcase_16 AC 91 ms
71,936 KB
testcase_17 AC 96 ms
76,544 KB
testcase_18 AC 89 ms
71,928 KB
testcase_19 AC 97 ms
76,536 KB
testcase_20 AC 92 ms
71,936 KB
testcase_21 AC 92 ms
71,580 KB
testcase_22 AC 92 ms
71,640 KB
testcase_23 AC 90 ms
71,804 KB
testcase_24 AC 91 ms
71,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#素因数分解、計算量はO(√N)
from collections import defaultdict
def factorize(n):
  dic = defaultdict(lambda: 0)
  b = 2
  while b * b <= n:
    while n % b == 0:
      n //= b
      dic[b] += 1
    b += 1
  if n > 1:
    dic[n] += 1
  return dic

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  d = factorize(A[i])
  for v in d.values():
    ans ^= v%3
print('Bob' if ans==0 else 'Alice')
0