Created
October 15, 2014 11:11
-
-
Save raven38/2ba0450d142a7eafe590 to your computer and use it in GitHub Desktop.
組み合わせの総数を求める。 combination
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
#define MOD 100000007 | |
long long comb(int P_, int Q_){ | |
static const int N_ = 1020; | |
static long long C_[N_][N_]; | |
if(C_[0][0]==0){ | |
int i,j; | |
for(i = 0; i < N_; ++i) C_[i][0] = C_[i][i] = 1; | |
for(i = 0; i < N_; ++i) for(j = 1; j < i; ++j) C_[i][j] = (C_[i-1][j-1] + C_[i-1][j])%MOD; | |
} | |
return C_[P_][Q_]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment