結果
| 問題 |
No.1514 Squared Matching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-11 08:36:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 688 bytes |
| コンパイル時間 | 180 ms |
| コンパイル使用メモリ | 82,104 KB |
| 実行使用メモリ | 849,812 KB |
| 最終ジャッジ日時 | 2024-09-21 16:48:02 |
| 合計ジャッジ時間 | 5,343 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 MLE * 1 -- * 24 |
ソースコード
def isqrt(n):
x = n
y = (x + 1) // 2
while y < x:
x = y
y = (x + n // x) // 2
return x
def primes(n):
is_prime = [True] * (n + 1)
is_prime[0] = False
is_prime[1] = False
for i in range(2, int(n ** 0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, n + 1, i):
is_prime[j] = False
return (i for i in range(n + 1) if is_prime[i])
N = int(input())
table = list(range(N + 1))
for p in primes(N):
p2 = p ** 2
for x in range(p2, N + 1, p2):
while not table[x] % p2:
table[x] //= p2
ans = 0
for a in range(1, N + 1):
ans += isqrt(N // table[a])
print(ans)