結果
問題 |
No.1746 Sqrt Integer Segments
|
ユーザー |
|
提出日時 | 2022-10-07 23:01:56 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 978 ms / 2,000 ms |
コード長 | 875 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 82,096 KB |
実行使用メモリ | 272,980 KB |
最終ジャッジ日時 | 2024-06-12 20:44:05 |
合計ジャッジ時間 | 24,888 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 |
ソースコード
import sys input = sys.stdin.readline from collections import * import random class Fast_factorize: def __init__(self, n): self.p = [-1]*(n+1) for i in range(2, n+1): if self.p[i]==-1: for j in range(i, n+1, i): if self.p[j]==-1: self.p[j] = i def factorize(self, n): res = [] while n>1: res.append(self.p[n]) n //= self.p[n] return res N = int(input()) A = list(map(int, input().split())) ff = Fast_factorize(10**6+10) x = random.sample(range(10**10, 10**18), 10**6+10) cnt = defaultdict(int) cnt[0] = 1 now = 0 ans = 0 for Ai in A: ps = Counter(ff.factorize(Ai)) for k, v in ps.items(): if v%2==1: now ^= x[k] ans += cnt[now] cnt[now] += 1 print(ans)