結果

問題 No.2609 Decreasing GCDs
コンテスト
ユーザー ntuda
提出日時 2025-10-31 23:34:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 42 ms / 1,000 ms
コード長 427 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,352 KB
実行使用メモリ 59,788 KB
最終ジャッジ日時 2025-10-31 23:34:33
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
N = int(input())
A = [1,2]
j = 3
i = 2
while i < N + 2:
    if gcd(j,A[i-2]) == 1 and gcd(j,A[i-1]) == 1:
        A.append(j)
        i += 1
    j += 1
B = []
for i in range(N+1):
    B.append(A[i]*A[i+1])
B = B[::-1]
j = 2
i = 1
while i < N:
    if B[i-1] < B[i] * j and gcd(B[i-1],j) == 1 and gcd(B[i],j)==1 and gcd(B[i+1],j) == 1:
        B[i] *= j
        i += 1
    j += 1
B = B[:-1]
print(*B[:N])



0