結果
問題 | No.103 素因数ゲーム リターンズ |
ユーザー |
|
提出日時 | 2022-10-14 04:25:43 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 71 ms / 5,000 ms |
コード長 | 1,336 bytes |
コンパイル時間 | 582 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 68,608 KB |
最終ジャッジ日時 | 2024-06-26 12:20:22 |
合計ジャッジ時間 | 4,093 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 20 |
ソースコード
from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N = int(input()) M = list(map(int,input().split())) class prime_factorize(): def __init__(self,M=10**6): self.sieve = [-1]*(M+1) self.sieve[1] = 1 self.p = [False]*(M+1) self.mu = [1]*(M+1) for i in range(2,M+1): if self.sieve[i] == -1: self.p[i] = True i2 = i**2 for j in range(i2,M+1,i2): self.mu[j] = 0 for j in range(i,M+1,i): self.sieve[j] = i self.mu[j] *= -1 def factors(self,x): tmp = [] while self.sieve[x] != x: tmp.append(self.sieve[x]) x //= self.sieve[x] tmp.append(self.sieve[x]) return tmp def is_prime(self,x): return self.p[x] def mobius(self,x): return self.mu[x] pf = prime_factorize(100000) ans = 0 for m in M: f = pf.factors(m) c = Counter(f) for v in c.values(): ans ^= (v%3) if ans: print('Alice') else: print('Bob')