結果

問題 No.1746 Sqrt Integer Segments
ユーザー chineristACchineristAC
提出日時 2021-11-18 01:30:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,536 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 86,840 KB
実行使用メモリ 138,516 KB
最終ジャッジ日時 2023-08-25 23:33:29
合計ジャッジ時間 11,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 161 ms
94,992 KB
testcase_01 AC 162 ms
94,820 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 212 ms
98,372 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 211 ms
138,496 KB
testcase_19 AC 213 ms
138,516 KB
testcase_20 AC 212 ms
138,512 KB
testcase_21 AC 230 ms
111,900 KB
testcase_22 AC 228 ms
111,428 KB
testcase_23 AC 202 ms
102,556 KB
testcase_24 AC 287 ms
132,852 KB
testcase_25 AC 281 ms
133,240 KB
testcase_26 AC 285 ms
133,152 KB
testcase_27 AC 382 ms
133,392 KB
testcase_28 AC 373 ms
133,104 KB
testcase_29 AC 377 ms
133,304 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
    
N = int(input())
A = [1] + li()

mod = 998244353
r = random.randint(2,1001)
pow_r = [1] * (M+1)
for i in range(1,M+1):
    pow_r[i] = pow_r[i-1] * r % mod

dic = {}

PS = [0]
for i in range(N):
    tmp_p = factorize(A[i+1])
    tmp_PS = PS[-1]
    for p in tmp_p:
        if p not in dic:
            dic[p] = 0
        tmp_PS += pow_r[p] * (1-2*dic[p]) % mod
        tmp_PS %= mod
        dic[p] = 1 - dic[p]
    PS.append(tmp_PS)

res = 0
PS.sort()
val = PS[0]
tmp = 1
for i in range(1,N+1):
    if val==PS[i]:
        tmp += 1
    else:
        res += tmp * (tmp-1)//2
        val = PS[i]
        tmp = 1
res += tmp * (tmp-1)//2
print(res)
exit()
check = 0
for i in range(N):
    dic = {}
    for j in range(i,N):
        for p in factorize(A[j+1]):
            if p not in dic:
                dic[p] = 0
            dic[p] = 1 - dic[p]
        if all(dic[p]==0 for p in dic):
            check += 1

print(check)
0