-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11401
48 lines (40 loc) · 746 Bytes
/
11401
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
using namespace std;
#define DIV 1000000007
long long temp;
long long power(long long a, long long m){
if(m==0) return 1;
temp=power(a, m/2)%DIV;
if(m%2==1) return temp*temp%DIV*a%DIV;
return temp*temp%DIV;
}
void solve(int n, int k){
if(k==1){
cout<<n;
return;
}
if(k==0||n==k){
cout<<1;
return;
}
if(n-k==1){
cout<<n;
return;
}
long long A=1, B=1, ans;
for(int i=n; i>=n-k+1; i--){
A=(A*i)%DIV;
}
for(int i=1; i<=k; i++){
B=(B*i)%DIV;
}
ans=((A%DIV)*power(B, DIV-2)%DIV)%DIV;
cout<<ans;
}
int main() {
//입력
int n, k;
cin>>n>>k;
solve(n,k);
return 0;
}