結果

問題 No.49 算数の宿題
ユーザー javyjavy
提出日時 2015-11-28 06:44:01
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 262 ms / 5,000 ms
コード長 1,620 bytes
コンパイル時間 13,305 ms
コンパイル使用メモリ 417,436 KB
実行使用メモリ 50,668 KB
最終ジャッジ日時 2023-08-24 17:27:56
合計ジャッジ時間 16,833 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 258 ms
50,668 KB
testcase_01 AC 255 ms
50,240 KB
testcase_02 AC 258 ms
50,408 KB
testcase_03 AC 258 ms
50,132 KB
testcase_04 AC 262 ms
50,372 KB
testcase_05 AC 261 ms
50,100 KB
testcase_06 AC 261 ms
50,420 KB
testcase_07 AC 262 ms
50,488 KB
testcase_08 AC 260 ms
50,420 KB
testcase_09 AC 257 ms
50,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:8:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

package Yukicoder

import java.util.regex.Pattern

/**
 * Created by hichikawa on 2015/11/12.
 */
fun main(args: Array<String>) {
    fun readLineLongArray(): List<Long> {
        val str = readLine() as String
        val arrStr = str.split(" ")
        val ret = arrStr.map { it.toLong() }
        return ret
    }

    fun readLineLong(): Long {
        val str = readLine() as String
        return str.toLong()
    }

    fun readLineInt(): Int {
        val str = readLine() as String
        return str.toInt()
    }

    fun readLineIntArray() : List<Int> {
        val str = readLine() as String
        val arrStr = str.split(" ")
        val ret = arrStr.map { it.toInt() }
        return ret
    }

    fun readLineDoubleArray(): List<Double> {
        val str = readLine() as String
        val arrStr = str.split(" ")
        val ret = arrStr.map { it.toDouble() }
        return ret
    }



    var str = readLine() as String
    val pTasu : Pattern = Pattern.compile("^(\\d+)\\+(\\d+)")
    val pKake : Pattern = Pattern.compile("^(\\d+)\\*(\\d+)")
//    val p : Pattern = Pattern.compile("(\\d+)\\+")
    while (true) {
        val mTasu = pTasu.matcher(str)
        if (mTasu.find()) {
            str = mTasu.replaceFirst((mTasu.group(1).toInt()*mTasu.group(2).toInt()).toString())
//            println(str)
            continue
        }
        val mKake = pKake.matcher(str)
        if (mKake.find()) {
            str = mKake.replaceFirst((mKake.group(1).toInt()+mKake.group(2).toInt()).toString())
//            println(str)
            continue
        }
        break
    }
    println(str)
}
0