๋ฐ์ํ
๋ฌธ์ ๋งํฌ
https://www.acmicpc.net/problem/11057
๋ด๊ฐ ํผ ํ์ด - ๋ง์์ต๋๋ค!
let n = Int(readLine()!)!
var dp = Array(repeating: Array(repeating: 0, count: 10), count: 1001)
//sum ํจ์ ๊ตฌํ
func sum(_ numbers: [Int]) -> Int {
return numbers.reduce(0, +)
}
// ํ์๋ฆฌ์๋ ๋ฌด์กฐ๊ฑด 1๊ฐ์ฉ
for i in 0...9 {
dp[1][i] = 1
}
if n == 1 {
print(sum(dp[1]))
} else {
for i in 2..<n+1 {
for j in 0...9 {
for k in j...9 {
dp[i][j] = (dp[i][j] + dp[i-1][k]) % 10007
}
}
}
print(sum(dp[n])%10007)
}
๋ฐ์ํ