結果
問題 | No.2199 lower_bound and upper_bound |
ユーザー | 👑 箱 |
提出日時 | 2022-05-04 05:58:12 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 367 ms / 2,000 ms |
コード長 | 1,661 bytes |
コンパイル時間 | 13,941 ms |
コンパイル使用メモリ | 447,160 KB |
実行使用メモリ | 83,132 KB |
最終ジャッジ日時 | 2024-04-15 16:04:46 |
合計ジャッジ時間 | 23,005 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 307 ms
51,720 KB |
testcase_01 | AC | 312 ms
51,816 KB |
testcase_02 | AC | 319 ms
53,704 KB |
testcase_03 | AC | 313 ms
51,892 KB |
testcase_04 | AC | 317 ms
51,856 KB |
testcase_05 | AC | 315 ms
51,712 KB |
testcase_06 | AC | 315 ms
51,912 KB |
testcase_07 | AC | 316 ms
52,036 KB |
testcase_08 | AC | 312 ms
51,916 KB |
testcase_09 | AC | 312 ms
51,692 KB |
testcase_10 | AC | 345 ms
66,272 KB |
testcase_11 | AC | 348 ms
66,280 KB |
testcase_12 | AC | 356 ms
75,428 KB |
testcase_13 | AC | 362 ms
82,872 KB |
testcase_14 | AC | 361 ms
82,908 KB |
testcase_15 | AC | 359 ms
83,028 KB |
testcase_16 | AC | 349 ms
75,772 KB |
testcase_17 | AC | 367 ms
80,232 KB |
testcase_18 | AC | 350 ms
74,648 KB |
testcase_19 | AC | 366 ms
81,288 KB |
testcase_20 | AC | 360 ms
80,452 KB |
testcase_21 | AC | 358 ms
83,132 KB |
testcase_22 | AC | 347 ms
66,124 KB |
testcase_23 | AC | 353 ms
76,120 KB |
testcase_24 | AC | 347 ms
67,200 KB |
ソースコード
fun main() { val (n, l, u) = readLongs() println(binom(2 * n + u, n) - binom(2 * n + l - 1, n) - binom(2 * n + u, n + u + 2) + binom(2 * n + l - 1, n + u + 2)) } // region ModInt class ModInt(x: Long) { companion object { const val MOD = 998244353L //const val MOD = 1000000007L } constructor(y: Int) : this(y.toLong()) 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 equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false other as ModInt if (x != other.x) return false return true } override fun hashCode(): Int { return x.hashCode() } override fun toString(): String { return "$x" } } fun binom(n: Long, k: Long): ModInt { var numer = ModInt(1) var denom = ModInt(1) for (i in 0 until k) { numer *= ModInt(n - i) denom *= ModInt(k - i) } return numer / denom } // endregion fun readLongs() = readln().split(" ").map { it.toLong() }