結果

問題 No.1299 Random Array Score
ユーザー rutilicusrutilicus
提出日時 2020-12-16 22:58:21
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 651 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 15,725 ms
コンパイル使用メモリ 435,788 KB
実行使用メモリ 79,760 KB
最終ジャッジ日時 2023-10-20 09:56:28
合計ジャッジ時間 38,348 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 332 ms
58,636 KB
testcase_01 AC 339 ms
58,648 KB
testcase_02 AC 339 ms
58,644 KB
testcase_03 AC 648 ms
79,748 KB
testcase_04 AC 651 ms
79,760 KB
testcase_05 AC 630 ms
73,564 KB
testcase_06 AC 618 ms
73,564 KB
testcase_07 AC 617 ms
73,564 KB
testcase_08 AC 644 ms
79,728 KB
testcase_09 AC 435 ms
59,032 KB
testcase_10 AC 550 ms
65,340 KB
testcase_11 AC 500 ms
61,144 KB
testcase_12 AC 611 ms
71,516 KB
testcase_13 AC 634 ms
79,728 KB
testcase_14 AC 599 ms
73,588 KB
testcase_15 AC 603 ms
73,556 KB
testcase_16 AC 610 ms
73,564 KB
testcase_17 AC 508 ms
61,136 KB
testcase_18 AC 543 ms
65,340 KB
testcase_19 AC 550 ms
67,380 KB
testcase_20 AC 512 ms
61,160 KB
testcase_21 AC 398 ms
58,948 KB
testcase_22 AC 493 ms
61,128 KB
testcase_23 AC 604 ms
73,564 KB
testcase_24 AC 618 ms
73,556 KB
testcase_25 AC 606 ms
73,564 KB
testcase_26 AC 413 ms
58,948 KB
testcase_27 AC 505 ms
61,136 KB
testcase_28 AC 504 ms
61,124 KB
testcase_29 AC 506 ms
61,132 KB
testcase_30 AC 606 ms
71,516 KB
testcase_31 AC 509 ms
61,172 KB
testcase_32 AC 625 ms
79,728 KB
testcase_33 AC 643 ms
79,732 KB
testcase_34 AC 575 ms
67,396 KB
testcase_35 AC 640 ms
79,736 KB
testcase_36 AC 579 ms
67,396 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:7:10: warning: variable 'n' is never used
    val (n, k) = readInputLine().split(" ").map { it.toLong() }
         ^
Main.kt:10:13: warning: 'appendln(Long): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
    builder.appendln(aArr.sum() % mod * pow(2L, k, mod) % mod)
            ^

ソースコード

diff #

fun main() {
    val builder = StringBuilder()

    // 数学嫌いが悪化している気がする
    val mod = 998244353L

    val (n, k) = readInputLine().split(" ").map { it.toLong() }
    val aArr = readInputLine().split(" ").map { it.toLong() }.toLongArray()

    builder.appendln(aArr.sum() % mod * pow(2L, k, mod) % mod)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}

fun pow(x: Long, n: Long, mod: Long): Long {
    var ret = 1L
    var base = x
    var nTmp = n

    while (nTmp != 0L) {
        if (nTmp % 2L != 0L) {
            ret = ret * base % mod
        }
        base = base * base % mod
        nTmp /= 2L
    }

    return ret
}
0