結果

問題 No.1058 素敵な数
ユーザー O2MTO2MT
提出日時 2020-08-15 01:53:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-04-18 23:30:35
合計ジャッジ時間 1,181 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,624 KB
testcase_01 AC 57 ms
13,184 KB
testcase_02 AC 54 ms
13,184 KB
testcase_03 AC 60 ms
13,056 KB
testcase_04 AC 56 ms
13,056 KB
testcase_05 AC 52 ms
13,056 KB
testcase_06 AC 52 ms
13,056 KB
testcase_07 AC 55 ms
13,184 KB
testcase_08 AC 51 ms
13,056 KB
testcase_09 AC 54 ms
13,056 KB
権限があれば一括ダウンロードができます

ソースコード

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())

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-2]
print(ans)

0