結果

問題 No.269 見栄っ張りの募金活動
ユーザー yudedakoyudedako
提出日時 2022-01-10 18:50:45
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 344 ms / 5,000 ms
コード長 682 bytes
コンパイル時間 11,912 ms
コンパイル使用メモリ 438,820 KB
実行使用メモリ 55,568 KB
最終ジャッジ日時 2024-04-26 20:15:28
合計ジャッジ時間 21,165 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
51,808 KB
testcase_01 AC 305 ms
54,956 KB
testcase_02 AC 288 ms
51,616 KB
testcase_03 AC 322 ms
55,428 KB
testcase_04 AC 338 ms
55,308 KB
testcase_05 AC 309 ms
55,040 KB
testcase_06 AC 305 ms
55,068 KB
testcase_07 AC 344 ms
55,344 KB
testcase_08 AC 316 ms
55,028 KB
testcase_09 AC 279 ms
51,852 KB
testcase_10 AC 303 ms
54,932 KB
testcase_11 AC 331 ms
55,568 KB
testcase_12 AC 278 ms
51,580 KB
testcase_13 AC 312 ms
54,976 KB
testcase_14 AC 295 ms
55,144 KB
testcase_15 AC 317 ms
55,288 KB
testcase_16 AC 283 ms
51,764 KB
testcase_17 AC 279 ms
51,760 KB
testcase_18 AC 331 ms
55,560 KB
testcase_19 AC 313 ms
55,256 KB
testcase_20 AC 304 ms
54,992 KB
testcase_21 AC 318 ms
55,076 KB
testcase_22 AC 318 ms
55,280 KB
testcase_23 AC 306 ms
55,036 KB
testcase_24 AC 323 ms
55,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const val MOD = 1000000007
fun main() {
    val (n, target, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val initial = n * (n - 1) / 2 * k
    if (initial !in 0 .. target) {
        println(0)
        return
    }
    val memo = IntArray(target - initial + 1).also{it[0] = 1}
    for (i in 0 until n) {
        val rest = n - i
        val sum = IntArray(rest)
        for (j in memo.indices) {
            sum[j % rest] = (sum[j % rest] + memo[j]) % MOD
        }
        for (j in memo.lastIndex downTo rest) {
            val s = sum[j % rest]
            sum[j % rest] = (s - memo[j] + MOD) % MOD
            memo[j] = s
        }
    }
    println(memo.last())
}
0