結果
問題 | No.2791 Beginner Contest |
ユーザー |
|
提出日時 | 2023-12-22 04:52:01 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 297 ms / 2,000 ms |
コード長 | 997 bytes |
コンパイル時間 | 12,405 ms |
コンパイル使用メモリ | 442,444 KB |
実行使用メモリ | 63,080 KB |
最終ジャッジ日時 | 2024-06-21 20:51:02 |
合計ジャッジ時間 | 17,992 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
import java.io.PrintWriterimport java.util.*import kotlin.math.*fun PrintWriter.solve() {val n = nextInt()val k = nextInt()val dp = Array(n + 1) { 1L }val mod = 998244353Lfor (i in 1..n) {dp[i] = dp[i - 1] + if (i >= k) dp[i - k] else 0dp[i] %= mod}println(dp[n])}fun main() {Thread(null, {val writer = PrintWriter(System.out, false)writer.solve()writer.flush()}, "solve", abs(1L.shl(26))).apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }.apply { start() }.join()}// region Scannerprivate var st = StringTokenizer("")private val br = System.`in`.bufferedReader()fun next(): String {while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())return st.nextToken()}fun nextInt() = next().toInt()fun nextLong() = next().toLong()fun nextLine() = br.readLine()fun nextDouble() = next().toDouble()// endregion