結果
問題 | No.2199 lower_bound and upper_bound |
ユーザー | 👑 箱 |
提出日時 | 2022-05-04 05:50:28 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 369 ms / 2,000 ms |
コード長 | 1,691 bytes |
コンパイル時間 | 14,509 ms |
コンパイル使用メモリ | 448,156 KB |
実行使用メモリ | 82,908 KB |
最終ジャッジ日時 | 2024-04-15 16:05:18 |
合計ジャッジ時間 | 24,124 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 313 ms
51,816 KB |
testcase_01 | AC | 313 ms
51,748 KB |
testcase_02 | AC | 316 ms
53,452 KB |
testcase_03 | AC | 311 ms
51,820 KB |
testcase_04 | AC | 317 ms
51,712 KB |
testcase_05 | AC | 313 ms
51,908 KB |
testcase_06 | AC | 312 ms
51,748 KB |
testcase_07 | AC | 315 ms
51,936 KB |
testcase_08 | AC | 312 ms
51,744 KB |
testcase_09 | AC | 309 ms
51,968 KB |
testcase_10 | AC | 344 ms
66,116 KB |
testcase_11 | AC | 345 ms
66,056 KB |
testcase_12 | AC | 356 ms
75,592 KB |
testcase_13 | AC | 362 ms
82,676 KB |
testcase_14 | AC | 358 ms
82,908 KB |
testcase_15 | AC | 364 ms
82,704 KB |
testcase_16 | AC | 359 ms
75,928 KB |
testcase_17 | AC | 361 ms
80,224 KB |
testcase_18 | AC | 342 ms
74,596 KB |
testcase_19 | AC | 369 ms
81,060 KB |
testcase_20 | AC | 360 ms
80,284 KB |
testcase_21 | AC | 365 ms
82,888 KB |
testcase_22 | AC | 338 ms
66,092 KB |
testcase_23 | AC | 354 ms
76,292 KB |
testcase_24 | AC | 347 ms
67,204 KB |
ソースコード
fun main() { val (n, l, u) = readLongs() println(binomSimple(2 * n + u, n) - binomSimple(2 * n + l - 1, n) - binomSimple(2 * n + u, n + u + 2) + binomSimple(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 binomSimple(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() }