其实求的这个数的式子化简一下,就是C(N,M).....
#include <iostream> #include <algorithm> #include <cstdio> #define LL __int64 using namespace std; LL N,M; LL myc(LL n,LL r){ LL sum=1; for(LL i=1;i<=r;i++) sum=sum*(n-r+i)/i; return sum; } int main(){ while(scanf("%d%d",&N,&M),N||M){ LL ans=myc(N,M); printf("%I64d things taken %I64d at a time is %I64d exactly.\n",N,M,ans); } return 0; }
时间: 2024-11-05 14:41:44