結果

問題 No.81 すべて足すだけの簡単なお仕事です。
ユーザー javyjavy
提出日時 2015-11-28 06:26:40
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 2,565 bytes
コンパイル時間 14,322 ms
コンパイル使用メモリ 455,392 KB
実行使用メモリ 58,000 KB
最終ジャッジ日時 2024-04-30 10:59:32
合計ジャッジ時間 26,492 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 356 ms
57,680 KB
testcase_01 AC 364 ms
57,652 KB
testcase_02 AC 365 ms
57,780 KB
testcase_03 WA -
testcase_04 AC 381 ms
57,880 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 380 ms
57,824 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 357 ms
57,832 KB
testcase_14 AC 366 ms
57,800 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 349 ms
57,560 KB
testcase_26 AC 360 ms
57,856 KB
testcase_27 WA -
testcase_28 AC 352 ms
57,712 KB
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:8:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

package Yukicoder

import java.math.BigDecimal

/**
 * 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 readLineDouble(): Double {
        val str = readLine() as String
        return str.toDouble()
    }

    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
    }
    val num = readLineInt()
    var list = Array(num, {Array<Long>(2, {0})})
    for (i in 0..(num-1)) {
        val str = readLine() as String
        if (str.indexOf(".") != -1) {
            val plmi : Int = if (str.get(0) == '-') -1 else 1
            val arrStr = str.split(".")
            val tmp = arrStr.map { it.toLong() }
            list[i][0] = tmp[0]
            list[i][1] = tmp[1] * Math.pow(10.toDouble(), (10-arrStr[1].length).toDouble()).toLong() * plmi
        } else {
            list[i][0] = str.toLong()
        }
    }
    var ans1 : Long = 0.toLong()
    var ans2 : Long = 0.toLong()
    for (item in list) {
        ans1 += item[0]
        ans2 += item[1]
    }
//    println(ans1)
//    println(ans2)
    ans1 += ans2 / 10000000000
    ans2 = ans2 % 10000000000
//    if (ans1 >= 0 && ans2 >= 0) {
//        println(ans1.toString() + "." + java.lang.String.format("%010d",ans2))
//    } else if (ans1 < 0 && ans2 < 0) {
//        println(ans1.toString() + "." + java.lang.String.format("%010d",ans2*-1))
//    } else if (ans1 > 0 && ans2 < 0) {
//        println((ans1-1).toString() + "." + java.lang.String.format("%010d",(10000000000-ans2)))
//    } else if (ans1 < 0 && ans2 > 0) {
//        println((ans1+1).toString() + "." + java.lang.String.format("%010d",(10000000000-ans2)))
//    } else if (ans1 == 0.toLong() && ans2 < 0) {
//        println("-" + (ans1).toString() + "." + java.lang.String.format("%010d",(ans2*-1)).toString())
//    }
    println(ans1.toString() + "." + java.lang.String.format("%010d",ans2))
}
0