結果

問題 No.1058 素敵な数
ユーザー takakintakakin
提出日時 2020-05-22 22:06:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 12,032 KB
最終ジャッジ日時 2024-04-15 16:57:02
合計ジャッジ時間 1,172 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
12,032 KB
testcase_01 AC 45 ms
11,904 KB
testcase_02 AC 46 ms
11,776 KB
testcase_03 AC 45 ms
11,776 KB
testcase_04 AC 48 ms
11,904 KB
testcase_05 AC 46 ms
11,776 KB
testcase_06 AC 45 ms
11,904 KB
testcase_07 AC 46 ms
11,776 KB
testcase_08 AC 46 ms
11,776 KB
testcase_09 AC 45 ms
11,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]
P=primes(10**5+100)
PP=[]
for p in reversed(P):
  if p>10**5:
    PP.append(p)
  else:
    break
PPP=set()
for p1 in PP:
  for p2 in PP:
    PPP.add(p1*p2)
PPP=sorted(list(PPP))
if n==1:
  print(1)
else:
  print(PPP[n-2])
0