結果

問題 No.1746 Sqrt Integer Segments
ユーザー hir355hir355
提出日時 2021-11-18 00:45:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 734 ms / 2,000 ms
コード長 655 bytes
コンパイル時間 2,287 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 132,936 KB
最終ジャッジ日時 2023-10-11 10:37:19
合計ジャッジ時間 17,920 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 262 ms
88,896 KB
testcase_01 AC 266 ms
88,716 KB
testcase_02 AC 588 ms
111,132 KB
testcase_03 AC 453 ms
102,524 KB
testcase_04 AC 508 ms
107,496 KB
testcase_05 AC 714 ms
127,168 KB
testcase_06 AC 416 ms
99,788 KB
testcase_07 AC 329 ms
92,404 KB
testcase_08 AC 579 ms
112,308 KB
testcase_09 AC 695 ms
123,964 KB
testcase_10 AC 410 ms
99,940 KB
testcase_11 AC 682 ms
120,940 KB
testcase_12 AC 701 ms
125,208 KB
testcase_13 AC 713 ms
128,452 KB
testcase_14 AC 734 ms
124,732 KB
testcase_15 AC 703 ms
128,900 KB
testcase_16 AC 714 ms
132,936 KB
testcase_17 AC 550 ms
109,556 KB
testcase_18 AC 301 ms
118,688 KB
testcase_19 AC 304 ms
118,504 KB
testcase_20 AC 300 ms
118,668 KB
testcase_21 AC 439 ms
104,076 KB
testcase_22 AC 435 ms
103,892 KB
testcase_23 AC 355 ms
95,640 KB
testcase_24 AC 596 ms
112,820 KB
testcase_25 AC 610 ms
112,932 KB
testcase_26 AC 593 ms
121,176 KB
testcase_27 AC 393 ms
121,156 KB
testcase_28 AC 400 ms
114,052 KB
testcase_29 AC 402 ms
112,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        while n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

from random import randint
from collections import Counter

r = [randint(1, 1000000000000000000) for _ in range(1000000)]
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
for i in range(n):
    t = 0
    for pr in prime_factorize(a[i]):
        t ^= r[pr]
    b[i + 1] = b[i] ^ t
ans = 0
for v in Counter(b).values():
    ans += v * (v - 1) // 2
print(ans)
0