結果
| 問題 |
No.689 E869120 and Constructing Array 3
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-03-04 16:20:23 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 991 bytes |
| コンパイル時間 | 134 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 44,480 KB |
| 最終ジャッジ日時 | 2024-10-14 00:18:32 |
| 合計ジャッジ時間 | 11,004 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 1 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
import numpy as np
# %%
def prime_table(N):
"""Create prime table of interval [0, N)
Parameters
----------
N : int
Upper bound. N must be >= 2.
Returns
-------
tuple of two arrays.
is_prime: is_prime[i] = True iff i is prime.
primes: primes[i] = (i+1)-th prime
"""
is_prime = np.zeros(N, np.bool_)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, N, 2):
if p * p > N:
break
if is_prime[p]:
is_prime[p * p::p + p] = 0
primes = np.where(is_prime)[0]
return is_prime, primes
# %%
K = int(readline())
# %%
is_prime, primes = prime_table(10 ** 4)
# %%
n = 0
while (n + 1) * (n + 2) // 2 <= K:
n += 1
C = [1] * n + [2]
rest = K - n * (n + 1) // 2
# %%
C += (primes[10:][:rest] - 2).tolist()
print(len(C))
print(*C)
maspy