結果
問題 | No.2023 Tiling is Fun |
ユーザー | 👑 箱星 |
提出日時 | 2022-06-07 20:29:07 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 375 ms / 2,000 ms |
コード長 | 1,069 bytes |
コンパイル時間 | 15,320 ms |
コンパイル使用メモリ | 422,720 KB |
実行使用メモリ | 62,280 KB |
最終ジャッジ日時 | 2023-09-26 17:45:52 |
合計ジャッジ時間 | 22,887 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 301 ms
52,788 KB |
testcase_01 | AC | 358 ms
55,888 KB |
testcase_02 | AC | 350 ms
55,912 KB |
testcase_03 | AC | 358 ms
55,808 KB |
testcase_04 | AC | 312 ms
52,852 KB |
testcase_05 | AC | 350 ms
55,956 KB |
testcase_06 | AC | 353 ms
55,824 KB |
testcase_07 | AC | 370 ms
56,160 KB |
testcase_08 | AC | 359 ms
55,872 KB |
testcase_09 | AC | 371 ms
56,056 KB |
testcase_10 | AC | 361 ms
56,212 KB |
testcase_11 | AC | 308 ms
53,368 KB |
testcase_12 | AC | 307 ms
53,500 KB |
testcase_13 | AC | 305 ms
52,900 KB |
testcase_14 | AC | 359 ms
58,632 KB |
testcase_15 | AC | 359 ms
58,032 KB |
testcase_16 | AC | 352 ms
57,956 KB |
testcase_17 | AC | 373 ms
62,200 KB |
testcase_18 | AC | 375 ms
62,280 KB |
testcase_19 | AC | 368 ms
56,104 KB |
ソースコード
fun main() { val (a, b) = readLongs() fun fac(n: Long) = (1..n).map { ModInt(it) }.fold(ModInt(1), ModInt::times) println(fac(a + b - 2) / (fac(a - 1) * fac(b - 1))) } // region ModInt class ModInt(x: Long) { companion object { const val MOD = 998244353L } val x = (x % MOD + MOD) % MOD operator fun plus(other: ModInt): ModInt { return ModInt(x + other.x) } operator fun minus(other: ModInt): ModInt { return ModInt(x - other.x) } operator fun times(other: ModInt): ModInt { return ModInt(x * other.x) } operator fun div(other: ModInt): ModInt { return this * other.inv() } fun pow(exp: Long): ModInt { if (exp == 0L) return ModInt(1L) var a = pow(exp shr 1) a *= a if (exp and 1L == 0L) return a return this * a } fun inv(): ModInt { return this.pow(MOD - 2) } override fun toString(): String { return "$x" } } // endregion fun readLongs() = readln().split(" ").map { it.toLong() }