結果
問題 | No.1746 Sqrt Integer Segments |
ユーザー | mkawa2 |
提出日時 | 2021-11-18 09:04:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,015 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,580 KB |
実行使用メモリ | 135,564 KB |
最終ジャッジ日時 | 2024-06-07 11:59:16 |
合計ジャッジ時間 | 9,530 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 108 ms
95,564 KB |
testcase_01 | AC | 111 ms
95,396 KB |
testcase_02 | WA | - |
testcase_03 | AC | 228 ms
105,604 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 154 ms
98,944 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 | AC | 270 ms
116,456 KB |
testcase_18 | AC | 147 ms
112,384 KB |
testcase_19 | AC | 145 ms
112,640 KB |
testcase_20 | AC | 147 ms
112,252 KB |
testcase_21 | AC | 187 ms
104,192 KB |
testcase_22 | AC | 190 ms
104,216 KB |
testcase_23 | AC | 157 ms
99,712 KB |
testcase_24 | AC | 256 ms
113,536 KB |
testcase_25 | AC | 250 ms
113,664 KB |
testcase_26 | AC | 256 ms
113,920 KB |
testcase_27 | AC | 281 ms
113,664 KB |
testcase_28 | AC | 281 ms
113,664 KB |
testcase_29 | AC | 286 ms
113,664 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = 18446744073709551615 inf = 4294967295 md = 10**9+7 # md = 998244353 from random import randrange class Sieve: def __init__(self, n): self.plist = [2] # n以下の素数のリスト min_prime_factor = [2, 0]*(n//2+1) for x in range(3, n+1, 2): if min_prime_factor[x] == 0: min_prime_factor[x] = x self.plist.append(x) if x**2 > n: continue for y in range(x**2, n+1, 2*x): if min_prime_factor[y] == 0: min_prime_factor[y] = x self.min_prime_factor = min_prime_factor def isprime(self, x): return self.min_prime_factor[x] == x # これが素因数分解(prime factorization) def pfct(self, x): pp, ee = [], [] while x > 1: mpf = self.min_prime_factor[x] if pp and mpf == pp[-1]: ee[-1] += 1 else: pp.append(mpf) ee.append(1) x //= mpf return [(p, e) for p, e in zip(pp, ee)] from collections import Counter n = II() aa = LI() sv = Sieve(1000005) enc = {p: randrange(inf) for p in sv.plist} ss = [] ans = 0 for a in aa: pe = sv.pfct(a) cur = 0 for p, e in pe: if e & 1: cur ^= enc[p] ss.append(cur) cnt = Counter() cnt[0] = 1 ans = 0 x = 0 for s in ss: x ^= s ans += cnt[x] cnt[x] += 1 print(ans)