POJ 2084 Game of Connections
来源:互联网 发布:网络诈骗代办信用卡 编辑:程序博客网 时间:2024/05/21 14:05
/*高精度的Catalan数题目 公式: h ( n ) = h ( n - 1 ) * ( 4 * n - 2 ) / n + 1 */
Source Code
Problem: 2084 User: imutzcyMemory: 296K Time: 0MSLanguage: C++ Result: Accepted- Source Code
#include<functional>#include<algorithm>#include<iostream>#include<fstream>#include<sstream>#include<iomanip>#include<numeric>#include<cstring>#include<cassert>#include<cstdio>#include<string>#include<vector>#include<bitset>#include<queue>#include<stack>#include<cmath>#include<ctime>#include<list>#include<set>#include<map>using namespace std;const int MAX=100;const int BASE=10000;int a[101][MAX],i,j,n;void multiply(int *a,int Max,int b)//大数乘法{ int i,array=0; for(i=Max-1;i>=0;i--){ array+=b*a[i]; a[i]=array%BASE; array/=BASE; }} void divide(int *a,int Max,int b)//大数除法{ int i,div=0; for(i=0;i<=Max-1;i++){ div=div*BASE+a[i]; a[i]=div/b; div%=b; }}int main(){ memset(a[1],0,MAX*sizeof(int)); for(i=2,a[1][MAX-1]=1;i<101;i++){ memcpy(a[i],a[i-1],MAX*sizeof(int)); //h[1] = h[i-1] multiply(a[i],MAX,4*i-2); //h[i] * = (4 * i - 2); divide(a[i],MAX,i+1); //h[i] / = (i + 1); } while(cin>>n,n+1){ for(i=0;i<MAX&&a[n][i]==0;i++); //去掉数组前为 0 的数字 cout<<a[n][i++]; //输出第一个非0数 for(;i<MAX;i++) printf("%04d",a[n][i]); // %04d 输出后面的数,并每位都保持5位长度 cout<<endl; } return 0;}
- POJ 2084 Game of Connections
- poj 2084 Game of Connections
- POJ 2084 Game of Connections
- POJ-2084-Game of Connections
- poj 2084 Game of Connections
- poj 2084 Game of Connections
- [POJ] 2084 -> Game of Connections
- POJ 2084 Game of Connections
- poj 2084 Game of Connections
- POJ 2084 Game of Connections 笔记
- POJ-2084(Catalan数专题)(Game of Connections )
- POJ 2084 Game of Connections 卡特兰数
- POJ 2084 Game of Connections(卡特兰数,JAVA)
- POJ 2084 Game of Connections(JAVA练习)
- 卡特兰数:poj 2084 Game of Connections+hdu 1023
- Poj 2084 Game of Connections(高精度卡特兰数)
- POJ 2084:Game of Connections 大数+卡特兰数
- poj 2084 Game of Connections (卡特兰数,大数乘除)
- sql自连接
- 文字垂直排列
- 九度教程93题 N阶楼梯上楼问题 解题报告
- HDU 1023 Train Problem II
- Ubuntu如何默认启动到命令行
- POJ 2084 Game of Connections
- XPCOM指南-7_结束编写WebLock
- XPCOM指南-8_编写WebLock界面
- 【转】百万级访问网站前期的技术准备
- XPCOM指南-9_WebLock组件打包
- bit 1010 Maximum Sum
- 电脑上域用户通过代理服务器上网,共享WiFi给android
- 《跟我学Spring3》2.2节 笔记
- 使用httpclient、htmlcleaner 、xpath 采集新浪微博3G站点数据