2026-01-25 19:40:17 +09:00

25 lines
470 B
Swift

let N: Int = Int(readLine()!)!
let MOD: Int = 1000000000
var dp: [Int] = Array(repeating: 1, count: 10)
dp[0] = 0
for _ in 1..<N {
var next_dp: [Int] = Array(repeating: 0, count: 10)
for i in 0...9 {
if i == 0 {
next_dp[i] = dp[1]
}
else if i==9 {
next_dp[i] = dp[8]
}
else {
next_dp[i] = (dp[i-1] + dp[i+1])%MOD
}
}
dp = next_dp
}
print(dp.reduce(0,+)%MOD)