結果
問題 |
No.1514 Squared Matching
|
ユーザー |
|
提出日時 | 2022-08-11 09:03:03 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 753 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 81,968 KB |
実行使用メモリ | 849,540 KB |
最終ジャッジ日時 | 2024-09-21 17:09:06 |
合計ジャッジ時間 | 5,987 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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]) def main(): 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) main()