티스토리 뷰

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

//https://www.acmicpc.net/problem/15489
const [R, C, W] = require('fs').readFileSync('./dev/stdin').toString().trim().split(' ').map(Number);
const dp = [[1], [1, 1]];
const N = R + W - 2;

for (let i = 2; i <= N; i++) {
	dp[i] = [];
	dp[i][0] = 1;
	for (let j = 1; j < i; j++) {
		dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
	}
	dp[i][i] = 1;
}
let r = R - 1;
let c = C - 1;
let answer = 0;
for (let i = 1; i <= W; i++) {
	for (let j = 0; j < i; j++) {
		answer += dp[r][c + j];
	}
	r++;
}

console.log(answer);
728x90
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함