結果

問題 No.289 数字を全て足そう
コンテスト
ユーザー uchida_t
提出日時 2023-05-31 13:00:00
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
AC  
実行時間 349 ms / 1,000 ms
コード長 254 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,528 ms
コンパイル使用メモリ 459,552 KB
実行使用メモリ 53,744 KB
最終ジャッジ日時 2026-06-02 17:12:32
合計ジャッジ時間 20,597 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:5:9: warning: condition is always 'true'.
    if (result != null) {
        ^^^^^^^^^^^^^^
Main.kt:6:35: warning: 'fun <T> Iterable<T>.sumBy(selector: (T) -> Int): Int' is deprecated. Use sumOf instead.
        println(result.chunked(1).sumBy { it.toInt() })
                                  ^^^^^

ソースコード

diff #
raw source code

fun main(args: Array<String>) {
    val text = readLine()!!
    val regex = Regex("[^0-9]")
    val result = regex.replace(text, "")
    if (result != null) {
        println(result.chunked(1).sumBy { it.toInt() })
    } else {
        println(0)
    }
}
0