結果
問題 | No.1299 Random Array Score |
ユーザー |
![]() |
提出日時 | 2020-12-16 22:58:21 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 628 ms / 2,000 ms |
コード長 | 696 bytes |
コンパイル時間 | 13,651 ms |
コンパイル使用メモリ | 436,048 KB |
実行使用メモリ | 101,996 KB |
最終ジャッジ日時 | 2024-09-20 05:25:47 |
合計ジャッジ時間 | 33,546 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
コンパイルメッセージ
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) ^
ソースコード
fun main() {val builder = StringBuilder()// 数学嫌いが悪化している気がするval mod = 998244353Lval (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 = 1Lvar base = xvar nTmp = nwhile (nTmp != 0L) {if (nTmp % 2L != 0L) {ret = ret * base % mod}base = base * base % modnTmp /= 2L}return ret}