Created
October 15, 2014 12:31
-
-
Save raven38/be59a44bf6a30733684b 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
long long combination(int n, int r){ | |
long long i = 1; | |
int k = r>n-r?n-r:r, cnt; | |
if(k < 0) return 0; | |
for(cnt = 1; cnt <= k; cnt++){ | |
i *= n - cnt + 1; | |
i /= cnt | |
} | |
return i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment