結果
| 問題 |
No.719 Coprime
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-27 23:59:46 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 629 bytes |
| コンパイル時間 | 255 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 44,592 KB |
| 最終ジャッジ日時 | 2024-07-05 16:34:59 |
| 合計ジャッジ時間 | 35,078 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 WA * 35 |
ソースコード
import numpy as np
N = int(input())
def get_sieve_of_eratosthenes(n):
if not isinstance(n, int):
raise TypeError("n is int-type.")
if n < 2:
raise ValueError("n is more than 2")
data = [i for i in range(2, n + 1)]
for d in data:
data = [x for x in data if (x == d or x % d != 0)]
return data
so = get_sieve_of_eratosthenes(N)
so = np.array(so)
ans = sum(so)
for i in range(N):
a = so[i]
if a* a> N:
break
b = a+0
while b *a <=N:
b =b*a
c = so[so < N//a]
try:
c = c[-1]
except:
c =0
if b-a < a*c-a-c:
ans += a*c -a-c
else:
ans += b-a
print(ans)