Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <vector>
- #include <queue>
- #include <set>
- #include <map>
- #include <cstdio>
- #include <cstdlib>
- #include <cctype>
- #include <cmath>
- using namespace std;
- typedef unsigned long long LL;
- #define FOR(k,a,b) for(int k(a); k < (b); ++k)
- #define FORD(k,a,b) for(int k(a-1); k >= (b); --k)
- #define REP(k,a) for(int k=0; k < (a); ++k)
- #define ABS(a) ((a)>0?(a):-(a))
- typedef pair<int,int> pii;
- #define x first
- #define y second
- int main()
- {
- #ifdef HOME
- freopen ("in.txt","r",stdin);
- // freopen ("out.txt","w",stdout);
- #endif
- const int mSize=5001;
- const int mod=1e9+7;
- typedef int (array5k_t)[mSize];
- array5k_t* comb = new array5k_t[mSize];
- REP(i,mSize)
- comb[i][0]=1,comb[i][i]=1;
- FOR(i,1,mSize)
- FOR(j,1,i)
- {
- comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
- if(comb[i][j]>=mod)
- comb[i][j]-=mod;
- }
- int N,K,K1,K2;
- LL res=0;
- while(true)
- {
- scanf("%d %d",&N,&K);
- if(N==0 && K==0)
- break;
- if(N==1 || K>2*N-3)
- {
- //because k positive
- printf("0\n");
- continue;
- }
- --K;
- K1=K/2;
- K2=(K+1)/2;
- res=2LL*comb[N-2][K1]*comb[N-2][K2];
- res%=mod;
- printf("%lld\n",res);
- }
- delete[] comb;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment