IT/알고리즘

[백준] 차량번호판

남갯 2024. 12. 5. 19:08
728x90
SMALL

 

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

fun main() = with(Scanner(System.`in`)) {
    val line = nextLine()
    val d = 10
    val c = 26
    var lastLetter = line[0]
    var result = if (line[0] == 'd') d else c
    for (i in 1 until line.length) {
        if (lastLetter == line[i]) {
            result *= if(line[i] == 'd') (d - 1) else (c - 1)
        } else {
            result *= if(line[i] == 'd') d else c
        }
        lastLetter = line[i]
    }
    println(result)
}

 

728x90
LIST