Little Jay

[C++] 백준 1010 - 다리놓기 본문

알고리즘/BOJ

[C++] 백준 1010 - 다리놓기

Jay, Lee 2021. 9. 20. 17:43

간단한 파스칼 삼각형 구하는 문제

 

#include<iostream>
#include<algorithm>
using namespace std;

int bridges[31][31];

int main() {

	ios::sync_with_stdio(false); 
	cin.tie(NULL); 

	for (int i = 1; i <= 30; i++)
		bridges[1][i] = i;

	for (int i = 2; i <= 30; i++) {
		for (int j = i; j <= 30; j++) {
			for (int k = j - 1; k >= 1; k--) {
				bridges[i][j] += bridges[i - 1][k];
			}
		}
	}

	int t; 
	cin >> t;

	while (t--) {
		int n, m; cin >> n >> m;
		cout << bridges[n][m] << "\n";
	}
	return 0;
}

'알고리즘 > BOJ' 카테고리의 다른 글

[C++] 백준 1712번 - 손익분기점  (0) 2021.09.25
[C++] 백준 10808번 - 알파벳 개수  (0) 2021.09.25
[C++] 백준 16768번 - Mooyo Mooyo  (0) 2021.09.20
[C++]백준 14502 - 연구소  (0) 2021.09.19
[C++] 백준 15683번 - 감시  (0) 2021.09.18
Comments