結果

問題 No.1058 素敵な数
ユーザー 👑 KazunKazun
提出日時 2020-09-04 01:55:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 58,112 KB
最終ジャッジ日時 2024-05-03 11:44:09
合計ジャッジ時間 1,078 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,376 KB
testcase_01 AC 36 ms
52,480 KB
testcase_02 AC 40 ms
57,720 KB
testcase_03 AC 40 ms
57,472 KB
testcase_04 AC 41 ms
58,112 KB
testcase_05 AC 41 ms
57,472 KB
testcase_06 AC 41 ms
57,472 KB
testcase_07 AC 42 ms
56,960 KB
testcase_08 AC 43 ms
57,872 KB
testcase_09 AC 43 ms
57,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#次の素数
def Next_Prime(N,K=1):
    """
    Nを上回る自然数のうち,K番目に小さい素数

    N:自然数
    """
    if K>0:
        while K>0:
            N+=1
            if Is_Prime(N):
                K-=1
    else:
        while K<0:
            N-=1
            if Is_Prime(N):
                K+=1
    return N

#素数判定
def Is_Prime(N):
    N=abs(N)
    if N<=1:
        return False

    k=2
    while k*k<=N:
        if N%k==0:
            return False
        k+=1
    return True
#================================================
N=int(input())

if N==1:
    print(1)
    exit()

N-=1
T=[]
for i in range(1,N+1):
    T.append(Next_Prime(10**5,i))

P=list(set(a*b for a in T for b in T))
P.sort()
print(P[N-1])
0