結果

問題 No.1058 素敵な数
ユーザー O2MTO2MT
提出日時 2020-08-15 01:51:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-04-18 23:30:26
合計ジャッジ時間 1,297 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
def primes(n):
  m = n*2
  is_prime = [True] * (m + 1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(m**0.5) + 1):
      if not is_prime[i]:
          continue
      for j in range(i * 2, m + 1, i):
          is_prime[j] = False
  return [i for i in range(m + 1) if is_prime[i]]

N = int(input())
m = 10**5
ans = 0

if N == 1:
  ans = 1
else:
  l = primes(10**5)
  b = bisect_left(l,10**5+1)
  l = l[b:b+11]
  ansList = []
  for i in range(len(l)):
    for j in range(len(l)):
      ansList.append(l[i]*l[j])
  ansList = list(set(ansList))
  ansList.sort()
  ans = ansList[N-1]
print(ans)
0