結果

問題 No.2609 Decreasing GCDs
ユーザー nikoro256nikoro256
提出日時 2024-01-19 22:12:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 1,000 ms
コード長 1,153 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 89,260 KB
最終ジャッジ日時 2024-01-19 22:12:06
合計ジャッジ時間 4,765 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
88,748 KB
testcase_01 AC 135 ms
88,748 KB
testcase_02 AC 139 ms
88,748 KB
testcase_03 AC 137 ms
88,748 KB
testcase_04 AC 154 ms
88,748 KB
testcase_05 AC 139 ms
88,748 KB
testcase_06 AC 135 ms
88,748 KB
testcase_07 AC 136 ms
88,748 KB
testcase_08 AC 137 ms
88,748 KB
testcase_09 AC 137 ms
89,260 KB
testcase_10 AC 136 ms
89,260 KB
testcase_11 AC 139 ms
89,260 KB
testcase_12 AC 179 ms
89,260 KB
testcase_13 AC 134 ms
89,260 KB
testcase_14 AC 137 ms
89,260 KB
testcase_15 AC 140 ms
89,260 KB
testcase_16 AC 134 ms
89,260 KB
testcase_17 AC 141 ms
89,260 KB
testcase_18 AC 133 ms
89,260 KB
testcase_19 AC 162 ms
89,260 KB
testcase_20 AC 134 ms
89,260 KB
testcase_21 AC 138 ms
89,260 KB
testcase_22 AC 136 ms
89,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 素数列挙 (区間指定可)
def getPrimes(last: int, first: int = 1):
    # validation check
    if not isinstance(last, int) or \
        not isinstance(first, int):
        raise("[ERROR] parameter must be integer")
    if last < 0 or first < 0:
        raise("[ERROR] parameter must be not less than 0 (first >= 0 & last >= 0)")

    if last < first:
        last, first = first, last
    isPrime = [True] * (last + 1)    # 素数かどうか
    # 0と1をFalseに
    isPrime[0] = isPrime[1] = False
    for i in range(2, int(last ** 0.5 + 1)):
        if isPrime[i]:
            # 篩にかける。iの倍数をすべてFalseにしていく。このとき i^2まではすでにふるい落とされているので見る必要がない
            for j in range(i ** 2, last + 1, i):
                isPrime[j] = False
    return [i for i in range(first, last + 1) if isPrime[i]] 

import bisect
N=int(input())
pr=getPrimes(2000000,1)
lis=[pr[N-i]*pr[N-i-1] for i in range(N)]
pr=pr[N:]
pos=1
idx=0
while True:
    if pr[idx]*lis[pos]>lis[pos-1]:
        lis[pos]*=pr[idx]
        pos+=1
    if pos==N:
        break
    idx+=1
print(*lis)
0