結果
問題 | No.1746 Sqrt Integer Segments |
ユーザー | chineristAC |
提出日時 | 2021-11-18 01:36:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,459 ms / 2,000 ms |
コード長 | 1,705 bytes |
コンパイル時間 | 410 ms |
コンパイル使用メモリ | 82,104 KB |
実行使用メモリ | 227,300 KB |
最終ジャッジ日時 | 2024-09-13 09:25:52 |
合計ジャッジ時間 | 28,677 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 412 ms
179,952 KB |
testcase_01 | AC | 419 ms
179,848 KB |
testcase_02 | AC | 1,115 ms
213,316 KB |
testcase_03 | AC | 744 ms
193,372 KB |
testcase_04 | AC | 865 ms
204,172 KB |
testcase_05 | AC | 1,333 ms
226,448 KB |
testcase_06 | AC | 659 ms
190,168 KB |
testcase_07 | AC | 495 ms
183,032 KB |
testcase_08 | AC | 1,046 ms
212,700 KB |
testcase_09 | AC | 1,345 ms
226,984 KB |
testcase_10 | AC | 662 ms
189,976 KB |
testcase_11 | AC | 1,315 ms
222,180 KB |
testcase_12 | AC | 1,390 ms
227,300 KB |
testcase_13 | AC | 1,389 ms
227,028 KB |
testcase_14 | AC | 1,459 ms
227,168 KB |
testcase_15 | AC | 1,376 ms
227,284 KB |
testcase_16 | AC | 1,359 ms
227,168 KB |
testcase_17 | AC | 932 ms
209,324 KB |
testcase_18 | AC | 532 ms
216,472 KB |
testcase_19 | AC | 525 ms
216,476 KB |
testcase_20 | AC | 530 ms
216,600 KB |
testcase_21 | AC | 521 ms
198,916 KB |
testcase_22 | AC | 512 ms
198,900 KB |
testcase_23 | AC | 452 ms
187,220 KB |
testcase_24 | AC | 642 ms
220,608 KB |
testcase_25 | AC | 625 ms
220,728 KB |
testcase_26 | AC | 626 ms
220,472 KB |
testcase_27 | AC | 1,040 ms
222,156 KB |
testcase_28 | AC | 1,054 ms
222,280 KB |
testcase_29 | AC | 1,076 ms
222,536 KB |
ソースコード
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() K = 3 mod = 998244353 r = [random.randint(2,mod-2) for i in range(K)] pow_r = [[1 for j in range(K)] for i in range(M+1)] for i in range(1,M+1): for j in range(K): pow_r[i][j] = pow_r[i-1][j] * r[j] % mod dic = {} PS = [[0,0,0]] for i in range(N): tmp_p = factorize(A[i+1]) tmp_PS = [PS[-1][j] for j in range(K)] for p in tmp_p: if p not in dic: dic[p] = 0 for j in range(K): tmp_PS[j] += pow_r[p][j] * (1-2*dic[p]) % mod tmp_PS[j] %= 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)