結果
| 問題 |
No.719 Coprime
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-07-28 00:06:51 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 675 bytes |
| コンパイル時間 | 106 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 44,632 KB |
| 最終ジャッジ日時 | 2024-07-05 16:50:15 |
| 合計ジャッジ時間 | 34,727 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / 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)
d = []
for i in range(N):
a = so[i]
if a in d:
break
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
d.append(c)
else:
ans += b-a
print(ans)