結果

問題 No.1746 Sqrt Integer Segments
ユーザー roarisroaris
提出日時 2022-10-07 22:58:53
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 956 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 87,248 KB
実行使用メモリ 241,604 KB
最終ジャッジ日時 2023-09-03 14:53:02
合計ジャッジ時間 9,371 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 680 ms
241,604 KB
testcase_01 AC 683 ms
240,780 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0