結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー | s_shohei |
提出日時 | 2021-09-27 20:43:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 154 ms / 5,000 ms |
コード長 | 835 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 87,056 KB |
実行使用メモリ | 87,240 KB |
最終ジャッジ日時 | 2023-09-20 22:08:49 |
合計ジャッジ時間 | 5,281 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 147 ms
87,184 KB |
testcase_01 | AC | 146 ms
86,940 KB |
testcase_02 | AC | 143 ms
87,016 KB |
testcase_03 | AC | 143 ms
86,804 KB |
testcase_04 | AC | 145 ms
87,004 KB |
testcase_05 | AC | 145 ms
86,928 KB |
testcase_06 | AC | 140 ms
86,980 KB |
testcase_07 | AC | 139 ms
87,004 KB |
testcase_08 | AC | 142 ms
86,820 KB |
testcase_09 | AC | 145 ms
87,060 KB |
testcase_10 | AC | 150 ms
86,932 KB |
testcase_11 | AC | 148 ms
87,172 KB |
testcase_12 | AC | 154 ms
87,124 KB |
testcase_13 | AC | 146 ms
87,136 KB |
testcase_14 | AC | 143 ms
86,968 KB |
testcase_15 | AC | 144 ms
87,240 KB |
testcase_16 | AC | 144 ms
86,824 KB |
testcase_17 | AC | 148 ms
87,052 KB |
testcase_18 | AC | 147 ms
87,000 KB |
testcase_19 | AC | 149 ms
87,196 KB |
testcase_20 | AC | 143 ms
86,920 KB |
testcase_21 | AC | 145 ms
86,984 KB |
testcase_22 | AC | 145 ms
86,820 KB |
testcase_23 | AC | 147 ms
86,956 KB |
testcase_24 | AC | 147 ms
87,060 KB |
ソースコード
n = int(input()) a = list(map(int, input().split())) M = 10**6 bp = [0] * (M+10) for i in range(2, M+10): if bp[i] == 0: bp[i] = i for j in range(i*i, M+1, i): bp[j] = i def fact(n): arr=[] while n>1: now=n cnt=0 p=bp[now] while now % p == 0: now//=p cnt+=1 arr.append([p,cnt]) n=now return arr from functools import lru_cache @lru_cache(maxsize=None) def grundy(n): f = fact(n) if len(f)==0: return 0 # prime s=set() for p,cnt in f: s.add(n//p) if cnt>=2: s.add(n//(p*p)) g_set = set([grundy(i) for i in s]) g = 0 while g in g_set: g+=1 return g xor=0 for num in a: xor^=grundy(num) if xor==0: print("Bob") else: print("Alice")