HDU-1133 Buy the Ticket (Catalan数)
来源:互联网 发布:mac日历添加美国节日 编辑:程序博客网 时间:2024/05/22 15:09
公式:(m+n)!*(m-n+1)/(m+1)
简单的大数运算。看似有除法,可以约去,大数相乘就行了。
#include<iostream>#include<cstdio>#include<cstring>using namespace std ;int len;int M[305];void Mult(int *a,int k){int Curlen=0,tmp;int carry=0;for(int i=0;i<len;i++){tmp=a[i]*k+carry;a[Curlen++]=tmp%10000; //先前进制少了,存不下。 carry=tmp/10000;}if(carry) a[Curlen++]=carry; len=Curlen;}int main(){int n,m,T=1; while(scanf("%d %d",&m,&n),(n||m)){if(n>m){printf("Test #%d:\n0\n",T++);continue;}memset(M,0,sizeof(M));M[0]=1,len=1;for(int i=m+n;i>1;i--){if(i==m+1) continue;Mult(M,i);}if(n) Mult(M,m-n+1);printf("Test #%d:\n",T++);printf("%d",M[len-1]);for(int i=len-2;i>=0;i--) printf("%04d",M[i]);puts(""); } return 0 ;}
0 0
- hdu 1133 Buy the Ticket(Catalan数)
- HDU 1133 Buy the ticket catalan 数
- HDU-1133 Buy the Ticket (Catalan数)
- hdu 1133 Buy the Ticket(Catalan)
- hdu 1133 · 【Buy the Ticket】Catalan数+java大数类
- hdu 1133 Buy the Ticket(卡特兰数 + 高精度)
- hdu 1133 Buy the Ticket(卡特兰数)
- HDU 1133 Buy the Ticket(DP)
- hdu 1133 Buy the Ticket (dp)
- hdu 1133 Buy the Ticket
- buy the ticket hdu 1133
- HDU 1133 Buy the Ticket
- hdu 1133 Buy the Ticket
- hdu-1133-Buy the Ticket
- HDU-1133-Buy the Ticket
- HDU 1133 Buy the Ticket
- HDU 1133 Buy the Ticket
- hdu 1133 Buy the Ticket
- web.xml中的url-pattern写法规则及匹配过程
- 关于java中枚举类的简单例子
- shell脚本中读取文本
- 凯撒密码破译
- 闰年计算
- HDU-1133 Buy the Ticket (Catalan数)
- ApplicationMaster实现原理
- C++智能指针
- ubuntu安装dropbox
- 三星7存平板 Galaxy Table 3 T210如何进入安全模式
- 关于301重定向,以及做重定向中需要注意的
- IOS语言Object-c语言随笔(四)
- XAMPP与VMWARE端口占用冲突
- [HTTP]_[C/C++]_[获取URL里的域名主体]