結果

問題 No.1058 素敵な数
ユーザー rythem00359
提出日時 2020-08-26 13:50:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 36 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-11-07 07:11:04
合計ジャッジ時間 1,075 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import random
def miller(x):
    if x==2:return True
    elif x>2 and x&1==0:return False
    s,t=0,x-1
    while t&1==0:
        s,t=s+1,t>>1
    a=random.randint(1,x-1)
    if pow(a,t,x)==1:return True
    for i in range(0,s):
        if pow(a,pow(2,i)*t,x)==x-1:return True
    return False
n=int(input())
if n==1:print(1)
else:
    a=10**5+1
    p=[]
    ans=[]
    m=6
    while len(p)<m:
        if miller(a):p.append(a)
        a+=2
    for i in range(m):
        for j in range(i,m):
            ans.append(p[i]*p[j])
    ans.sort()
    print(ans[n-2])
0