結果
| 問題 |
No.1746 Sqrt Integer Segments
|
| ユーザー |
|
| 提出日時 | 2022-10-07 22:58:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 956 bytes |
| コンパイル時間 | 274 ms |
| コンパイル使用メモリ | 82,360 KB |
| 実行使用メモリ | 248,404 KB |
| 最終ジャッジ日時 | 2024-06-12 20:36:05 |
| 合計ジャッジ時間 | 6,423 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | TLE * 1 -- * 27 |
ソースコード
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)
now = defaultdict(int)
cnt = defaultdict(int)
cnt[0] = 1
x = random.sample(range(10**10, 10**18), 10**6+10)
ans = 0
for Ai in A:
ps = Counter(ff.factorize(Ai))
for k, v in ps.items():
now[k] ^= v%2
X = 0
for k, v in now.items():
if v==1:
X ^= x[k]
ans += cnt[X]
cnt[X] += 1
print(ans)