본문 바로가기

Programming/BaekJoon

[C++] 백준 1010번 : 다리 놓기


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




#include <iostream>

using namespace std;

int main() {

int n;

cin >> n;

int **T_c = new int*[n];

for (int i = 0; i < n; i++) {

T_c[i] = new int[2];

cin >> T_c[i][0] >> T_c[i][1];

}


long long tmp1 = 1, tmp2 = 1;

for (int i = 0; i < n; i++) {

if (T_c[i][1]  < T_c[i][0] * 2)

T_c[i][0] = T_c[i][1] - T_c[i][0];

for (int j = 0; j < T_c[i][0]; j++)

{

tmp1 = (j + 1)*tmp1;

tmp2 = (T_c[i][1] - j) * tmp2;

}

cout << tmp2 / tmp1 << "\n";

tmp1 = 1;

tmp2 = 1;

}

}