Created
October 25, 2015 10:27
-
-
Save bowbowbow/a5c3dec77cd3edd4d3fd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <memory.h> | |
using namespace std; | |
#define MAXN 1500 | |
int cashe[MAXN][MAXN]; | |
int binomial(int n, int k, int p){ | |
if(cashe[n][k] != -1 ) return cashe[n][k]; | |
if(k ==0 || k == n) | |
return cashe[n][k] = 1; | |
return cashe[n][k] = (binomial(n-1, k-1, p)+binomial(n-1, k, p))%p; | |
} | |
int main(){ | |
memset(cashe, -1, sizeof(cashe)); | |
int N, K; | |
cin >> N >> K; | |
cout << binomial(N, K, 7) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment