結果
問題 | No.2609 Decreasing GCDs |
ユーザー |
|
提出日時 | 2024-01-05 18:27:46 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 3,830 ms |
コンパイル使用メモリ | 66,992 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-27 20:07:28 |
合計ジャッジ時間 | 5,171 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 22 |
ソースコード
import strutils, sequtils, algorithmfunc isPrime(n: int): bool =if n < 2:return falsevar i = 2while i * i <= n:if n mod i == 0:return falseinc(i)return truefunc nextPrime(n: int): int =var i = n + 1while not isPrime(i):inc(i)return ilet n = stdin.readLine.parseIntvar result = newSeqWith(n, 1)var k = 1for i in 0 ..< n-1:k = nextPrime(k)result[i] *= kresult[i+1] *= kresult.reversefor i in 0 ..< n-1:let ratio = result[i] div result[i + 1] + 1result[i + 1] *= nextPrime(ratio.max(100))echo result.join(" ")