結果

問題 No.1746 Sqrt Integer Segments
ユーザー roarisroaris
提出日時 2022-10-07 23:01:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,083 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 285 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 269,696 KB
最終ジャッジ日時 2023-09-03 15:01:05
合計ジャッジ時間 29,752 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 677 ms
240,780 KB
testcase_01 AC 689 ms
240,548 KB
testcase_02 AC 966 ms
258,420 KB
testcase_03 AC 837 ms
251,832 KB
testcase_04 AC 907 ms
255,976 KB
testcase_05 AC 1,067 ms
269,320 KB
testcase_06 AC 827 ms
249,600 KB
testcase_07 AC 745 ms
243,816 KB
testcase_08 AC 928 ms
259,672 KB
testcase_09 AC 1,066 ms
267,768 KB
testcase_10 AC 778 ms
247,716 KB
testcase_11 AC 1,040 ms
269,480 KB
testcase_12 AC 1,041 ms
268,864 KB
testcase_13 AC 1,077 ms
268,412 KB
testcase_14 AC 1,060 ms
268,472 KB
testcase_15 AC 1,072 ms
269,696 KB
testcase_16 AC 1,083 ms
268,388 KB
testcase_17 AC 932 ms
257,228 KB
testcase_18 AC 735 ms
241,544 KB
testcase_19 AC 741 ms
241,848 KB
testcase_20 AC 750 ms
241,504 KB
testcase_21 AC 801 ms
241,736 KB
testcase_22 AC 801 ms
241,576 KB
testcase_23 AC 736 ms
240,792 KB
testcase_24 AC 889 ms
247,740 KB
testcase_25 AC 894 ms
248,432 KB
testcase_26 AC 926 ms
247,764 KB
testcase_27 AC 927 ms
248,072 KB
testcase_28 AC 960 ms
248,136 KB
testcase_29 AC 933 ms
248,188 KB
権限があれば一括ダウンロードができます

ソースコード

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)

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