結果
| 問題 |
No.1058 素敵な数
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-25 21:44:55 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 2,000 ms |
| コード長 | 1,537 bytes |
| コンパイル時間 | 122 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-10-13 02:15:11 |
| 合計ジャッジ時間 | 1,066 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
def is_prime(num):
""" 素数判定 """
from math import sqrt
if num < 2:
return False
if num in [2, 3, 5]:
return True
if num % 2 == 0 or num % 3 == 0 or num % 5 == 0:
return False
# 疑似素数(2でも3でも割り切れない数字)で次々に割っていく
prime = 7
step = 4
num_sqrt = sqrt(num)
while prime <= num_sqrt:
if num % prime == 0:
return False
prime += step
step = 6 - step
return True
N = INT()
ans = [1]
prime = []
cnt = 0
n = 10**5+1
while cnt <= 10:
if is_prime(n):
cnt += 1
prime.append(n)
n += 1
suteki = []
for i, j in combinations(prime, 2):
suteki.append(i*j)
for x in prime:
suteki.append(x**2)
suteki.sort()
ans += suteki
print(ans[N-1])