-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathK Candy Store.cpp
More file actions
56 lines (43 loc) · 1007 Bytes
/
K Candy Store.cpp
File metadata and controls
56 lines (43 loc) · 1007 Bytes
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
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
#define endl '\n'
#define lli long long int
#define ld long double
#define forn(i,n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define SZ(s) int(s.size())
using namespace std;
typedef vector<lli> VLL;
typedef vector<int> VI;
//13
const lli maxN = 1e3+1;
const lli MOD = 1e9;
int nCr[maxN+5][maxN+5];
void prec()
{
nCr[0][0] = 1;
for(int i = 1; i<maxN; i++)
{
for(int j = 0; j<=i; j++)
{
if(j==0 || j == i) nCr[i][j] = 1;
else
{
nCr[i][j] = (nCr[i-1][j-1] + nCr[i-1][j])%MOD;
}
//cout << nCr[i][j] << " ";
}
//cout << endl;
}
}
int main () {
fastIO();
prec();
int t; cin>>t;
while(t--)
{
int n, k; cin>>k>>n;
cout << nCr[n+k-1][k-1] << endl;
}
return 0;
}