IT/알고리즘

[백준] 2xn 타일링

남갯 2024. 11. 18. 21:06
728x90
SMALL

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

 

fun main() = with(Scanner(System.`in`)) {
    val size = nextInt()
    val count = Array<Int>(size + 1) { 0 }

    count[0] = 0
    count[1] = 1
    if(size == 1){
        return println(count[size])
    }
    count[2] = 2

    for (i in 3 until count.size) {
        count[i] = (count[i - 2] + count[i - 1]) % 10007
    }
    println(count[size])
}
728x90
LIST