結果

問題 No.1746 Sqrt Integer Segments
ユーザー chineristACchineristAC
提出日時 2021-11-28 02:49:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 635 ms / 2,000 ms
コード長 1,018 bytes
コンパイル時間 479 ms
コンパイル使用メモリ 87,408 KB
実行使用メモリ 135,440 KB
最終ジャッジ日時 2023-10-11 10:43:58
合計ジャッジ時間 18,907 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 425 ms
96,948 KB
testcase_01 AC 419 ms
97,120 KB
testcase_02 AC 566 ms
120,432 KB
testcase_03 AC 525 ms
110,672 KB
testcase_04 AC 547 ms
115,868 KB
testcase_05 AC 626 ms
135,244 KB
testcase_06 AC 495 ms
108,444 KB
testcase_07 AC 466 ms
100,296 KB
testcase_08 AC 576 ms
122,460 KB
testcase_09 AC 631 ms
135,440 KB
testcase_10 AC 509 ms
107,628 KB
testcase_11 AC 606 ms
128,768 KB
testcase_12 AC 628 ms
132,240 KB
testcase_13 AC 623 ms
132,276 KB
testcase_14 AC 635 ms
135,332 KB
testcase_15 AC 633 ms
135,308 KB
testcase_16 AC 628 ms
135,176 KB
testcase_17 AC 549 ms
117,992 KB
testcase_18 AC 475 ms
128,368 KB
testcase_19 AC 464 ms
128,424 KB
testcase_20 AC 475 ms
128,208 KB
testcase_21 AC 493 ms
112,284 KB
testcase_22 AC 492 ms
112,040 KB
testcase_23 AC 471 ms
103,784 KB
testcase_24 AC 552 ms
129,756 KB
testcase_25 AC 545 ms
129,992 KB
testcase_26 AC 555 ms
130,092 KB
testcase_27 AC 604 ms
130,060 KB
testcase_28 AC 594 ms
130,180 KB
testcase_29 AC 600 ms
130,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

M = 10**6
spf = [i for i in range(M+1)]
for i in range(2,M+1):
    if spf[i]==i:
        for j in range(i,M+1,i):
            spf[j] = i


def factorize(n):
    res = []
    while n!=1:
        p = spf[n]
        cnt = 0
        while n%p==0:
            cnt += 1
            n //= p
        if cnt&1:
            res.append(p)
    return res

rand_val = [random.randint(0,(1<<60)-1) for i in range(M+1)]
    
N = int(input())
A = [1] + li()

hash = [0 for i in range(N+1)]
for i in range(N+1):
    tmp_p = factorize(A[i])
    for p in tmp_p:
        hash[i] ^= rand_val[p]
for i in range(1,N+1):
    hash[i] ^= hash[i-1]

dic = {val:0 for val in hash}
for val in hash:
    dic[val] += 1

res = sum(k*(k-1)//2 for val,k in dic.items())
print(res)
0