44424742 发表于 2013-1-26 13:38:00

poj1942——Paths on a Grid//大数的C(n,m)

组合数学问题,求解c(n,m).数据类型要求甚严。用吉林模板的话,会tle。
#include<iostream>using namespace std;double com(doublen,doublem){double i;double s(1);if(n>=m-n) n=m-n;for(i=m;i>=m-n+1;i--){s*=(i/(i-(m-n)));}return s;}int main(){double n,m;while(scanf("%lf%lf",&n,&m)!=EOF){if(n==0&&m==0) break;printf("%.0lf\n",com(n,m+n));}return 0;}
页: [1]
查看完整版本: poj1942——Paths on a Grid//大数的C(n,m)