2011年8月20日

poj 1306 Combinations

摘要: 递归#include<iostream>//递归usingnamespace std;__int64 ans[200][200];__int64 f(int n,int m){ if(ans[n][m]>0) return ans[n][m]; if(n==m||m==0) return1; ans[n][m]=f(n-1,m)+f(n-1,m-1); //C(n,m)=C(n-1,m)+C(n-1,m-1)return ans[n][m];}int main(){ int n,m; while(cin>>n>>m&&n)... 阅读全文

posted @ 2011-08-20 10:07 sysu_mjc 阅读(109) 评论(0) 推荐(0) 编辑

poj 2249 Binomial Showdown

摘要: #include<iostream> //见poj 1306 Combinationsusing 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 阅读全文

posted @ 2011-08-20 09:43 sysu_mjc 阅读(112) 评论(0) 推荐(0) 编辑

导航