Skip to content

Instantly share code, notes, and snippets.

@raven38
Created October 15, 2014 12:31
Show Gist options
  • Save raven38/be59a44bf6a30733684b to your computer and use it in GitHub Desktop.
Save raven38/be59a44bf6a30733684b to your computer and use it in GitHub Desktop.
小さい方のcombination
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