세상을 더 좋게

[Baekjoon] 11382 The kid 'JungMin' (Kotlin) 꼬마 정민 (코틀린) 본문

Algorithm/[solved.ac] 새싹 Class

[Baekjoon] 11382 The kid 'JungMin' (Kotlin) 꼬마 정민 (코틀린)

나는SOU 2024. 3. 1. 18:00

https://www.acmicpc.net/problem/11382

 

11382번: 꼬마 정민

첫 번째 줄에 A, B, C (1 ≤ A, B, C ≤ 1012)이 공백을 사이에 두고 주어진다.

www.acmicpc.net

We need to concept in overflow to resolve this problem. The number received restricted in 10^15. So we do not use 'Int' but 'Long' type.

OVerflow occurs when there are insufficient bits in a binary number representation to portray the result of an arithmetic operation.

fun main() {
    val input = readLine()!!.split(" ")
    
    var result: Long = 0
    for (i in 0 until input.count()) {
        val number = input[i].toLong()
        result += number
    }
    println(result)
}