🧩PS/🥉Easy
[JAVA] 백준 11051번 - 이항 계수 2
Cocoon_
2021. 11. 18. 12:18
반응형
📖 문제
📋 코드
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int arr[][] = new int[N+1][N+1];
arr[0][0] = 1;
arr[0][1] = 1;
for (int i = 1; i <= N; i++) {
for (int j = 0; j <= i; j++) {
if(j == 0 || j == i) {
arr[i][j] = 1;
}else {
arr[i][j] = (arr[i-1][j-1] + arr[i-1][j])%10007;
}
}
}
System.out.println(arr[N][K]);
}
}
👨🏻💻 결과
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
...
🔗 링크
https://www.acmicpc.net/problem/11051
11051번: 이항 계수 2
첫째 줄에 \(N\)과 \(K\)가 주어진다. (1 ≤ \(N\) ≤ 1,000, 0 ≤ \(K\) ≤ \(N\))
www.acmicpc.net
반응형