結果

問題 No.1514 Squared Matching
ユーザー tktk_snsntktk_snsn
提出日時 2021-05-21 22:28:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,505 ms / 4,000 ms
コード長 400 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 82,544 KB
実行使用メモリ 466,620 KB
最終ジャッジ日時 2024-04-18 16:02:51
合計ジャッジ時間 26,321 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,536 KB
testcase_01 AC 1,505 ms
466,348 KB
testcase_02 AC 45 ms
52,180 KB
testcase_03 AC 37 ms
52,568 KB
testcase_04 AC 37 ms
52,568 KB
testcase_05 AC 48 ms
61,476 KB
testcase_06 AC 68 ms
77,676 KB
testcase_07 AC 297 ms
150,088 KB
testcase_08 AC 1,402 ms
452,256 KB
testcase_09 AC 1,164 ms
404,560 KB
testcase_10 AC 1,271 ms
432,232 KB
testcase_11 AC 1,328 ms
446,920 KB
testcase_12 AC 1,366 ms
457,468 KB
testcase_13 AC 1,391 ms
462,588 KB
testcase_14 AC 1,392 ms
464,512 KB
testcase_15 AC 1,380 ms
465,660 KB
testcase_16 AC 1,379 ms
466,088 KB
testcase_17 AC 1,382 ms
466,336 KB
testcase_18 AC 1,381 ms
466,412 KB
testcase_19 AC 1,374 ms
466,080 KB
testcase_20 AC 1,429 ms
466,196 KB
testcase_21 AC 1,364 ms
466,620 KB
testcase_22 AC 309 ms
153,676 KB
testcase_23 AC 556 ms
232,172 KB
testcase_24 AC 808 ms
310,096 KB
testcase_25 AC 1,092 ms
388,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
used = [0] * (N+1)
sq = []
for i in range(1, N+1):
    if i*i > N:
        break
    used[i*i] = 1
    sq.append(i*i)

ans = len(sq) ** 2
for x in range(1, N+1):
    if used[x]:
        continue

    cnt = 0
    for y in sq:
        if x * y > N:
            break
        if used[x * y]:
            continue
        used[x * y] = 1
        cnt += 1
    ans += cnt * cnt
print(ans)
0