poj 2249Binomial Showdown
简单排列组合题,输入n,m求n中选m个数的种类
#include<stdio.h> __int64 work(__int64 n,__int64 k) {//求在n个数中选m个数的组合数. __int64 i,sum,j = 1; if(k > n) return 0; //求组合数 for(sum = 1,i = k; i ; i--) { sum *= n--; while(sum%j == 0 && j <= k) sum /= j++; } return sum; } int main() { __int64 n,m; while(scanf("%I64d%I64d",&n,&m) != EOF&& n+m) { if((m<<2) > n) m = n-m; printf("%I64d\n",work(n,m)); } return 0; }