poj 2249 Binomial Showdown

#include<iostream>            //见poj 1306 Combinations
using namespace std;
int main()
{
double n,k,i,j;
while(cin>>n>>k&&n!=0)
{
double res=1;
for(i=n,j=min(n-k,k);j>=1;--i,--j)
{
res
*=i/j;
}
printf(
"%.0f\n",res);
}
return 0;
}



#include
<iostream>
using namespace std;
int main()
{
double n,k,i,j;
while(cin>>n>>k&&n!=0)
{
double r1=1,r2=1;
for(i=n,j=min(n-k,k);j>=1;--i,--j)
{
r1
*=i;
r2
*=j;
}
printf(
"%.0f\n",r1/r2);
}
return 0;
}

  

posted on 2011-08-20 09:43  sysu_mjc  阅读(114)  评论(0编辑  收藏  举报

导航