結果

問題 No.1058 素敵な数
ユーザー uni_pythonuni_python
提出日時 2020-06-18 23:38:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 1,149 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 78,288 KB
最終ジャッジ日時 2023-09-12 18:08:56
合計ジャッジ時間 1,903 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
78,000 KB
testcase_01 AC 90 ms
78,092 KB
testcase_02 AC 89 ms
78,268 KB
testcase_03 AC 89 ms
77,856 KB
testcase_04 AC 89 ms
78,244 KB
testcase_05 AC 90 ms
78,144 KB
testcase_06 AC 92 ms
78,000 KB
testcase_07 AC 89 ms
78,208 KB
testcase_08 AC 90 ms
78,184 KB
testcase_09 AC 90 ms
78,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

def main():
    #nまでの素数を列挙(n loglogn)
    N=I()
    n = 3*(10**5)

    #is_prime[i]にはi-1が素数か否かを示すboolが入る,[0]に1の素数判定がある.
    is_prime = [True]*(n+1)
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i

    table=[]
    for i in range(10**5,n):
        if is_prime[i]:
            table.append(i+1)
        if len(table)>=100:
            break
    
    ans=[1]
    M=len(table)
    
    for i in range(M):
        for j in range(M):
            ans.append(table[i]*table[j])
    ans=list(set(ans))
    ans.sort()
    print(ans[N-1])
            


main()
0