結果

問題 No.1514 Squared Matching
ユーザー convexineqconvexineq
提出日時 2021-05-21 22:10:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 3,217 ms / 4,000 ms
コード長 463 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 468,172 KB
最終ジャッジ日時 2024-04-18 15:41:15
合計ジャッジ時間 47,438 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,504 KB
testcase_01 AC 2,590 ms
467,944 KB
testcase_02 AC 40 ms
53,120 KB
testcase_03 AC 41 ms
53,760 KB
testcase_04 AC 41 ms
54,272 KB
testcase_05 AC 51 ms
63,872 KB
testcase_06 AC 101 ms
82,560 KB
testcase_07 AC 523 ms
151,036 KB
testcase_08 AC 2,499 ms
453,556 KB
testcase_09 AC 2,277 ms
406,372 KB
testcase_10 AC 2,596 ms
433,920 KB
testcase_11 AC 2,680 ms
448,320 KB
testcase_12 AC 3,217 ms
459,088 KB
testcase_13 AC 2,779 ms
464,148 KB
testcase_14 AC 2,573 ms
465,772 KB
testcase_15 AC 3,091 ms
467,084 KB
testcase_16 AC 2,969 ms
467,640 KB
testcase_17 AC 2,578 ms
467,780 KB
testcase_18 AC 2,714 ms
467,592 KB
testcase_19 AC 2,555 ms
467,840 KB
testcase_20 AC 2,605 ms
468,172 KB
testcase_21 AC 2,558 ms
467,828 KB
testcase_22 AC 540 ms
154,752 KB
testcase_23 AC 1,059 ms
232,948 KB
testcase_24 AC 1,549 ms
311,364 KB
testcase_25 AC 2,171 ms
389,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isqrt(n):
    assert n >= 0
    if n < 2: return n
    x = int(n**0.5)*2
    while x*x > n:
        x = (x+n//x)//2
    return x

n = int(input())
r = [1]*(n+1)
from collections import defaultdict
d = defaultdict(int)
for i in range(1,n+1):
    if r[i] == 0: continue
    c = 0
    for j in range(1,n+1):
        v = i*j*j
        if v > n: break
        c += 1
        r[v] = 0
    d[n//i] += c

ans = 0
for k,v in d.items():
    ans += isqrt(k)*v
print(ans)
0