【高精度】NCPC 2014 C catalansqure

题目链接:

  http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1789

题目大意:

  求大卡特兰数。。公式如下。输入n求Sn(n<=5000)

题目思路:

  【高精度】

  Sn=Cn+1。直接压四位高精度算一遍就好。只要写高精度乘单精度,高精度除单精度。

 

 1 //
 2 //by coolxxx
 3 //#include<bits/stdc++.h>
 4 #include<iostream>
 5 #include<algorithm>
 6 #include<string>
 7 #include<iomanip>
 8 #include<map>
 9 #include<stack>
10 #include<queue>
11 #include<set>
12 #include<bitset>
13 #include<memory.h>
14 #include<time.h>
15 #include<stdio.h>
16 #include<stdlib.h>
17 #include<string.h>
18 //#include<stdbool.h>
19 #include<math.h>
20 #define min(a,b) ((a)<(b)?(a):(b))
21 #define max(a,b) ((a)>(b)?(a):(b))
22 #define abs(a) ((a)>0?(a):(-(a)))
23 #define lowbit(a) (a&(-a))
24 #define sqr(a) ((a)*(a))
25 #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
26 #define mem(a,b) memset(a,b,sizeof(a))
27 #define eps (1e-8)
28 #define J 10000
29 #define mod 1000000007
30 #define MAX 0x7f7f7f7f
31 #define PI 3.14159265358979323
32 #define N 20004
33 using namespace std;
34 typedef long long LL;
35 int cas,cass;
36 int n,m,lll,ans;
37 int a[N];
38 void gjdchengdjd(int a[],int b)
39 {
40     int i;
41     for(i=1;i<=a[0];i++)
42         a[i]*=b;
43     for(i=1;i<=a[0];i++)
44         a[i+1]+=a[i]/J,a[i]%=J;
45     while(a[a[0]+1])a[0]++;
46 }
47 void gjdchudjd(int a[],int b)
48 {
49     int i;
50     for(i=a[0];i>1;i--)
51         a[i-1]+=(a[i]%b)*J,a[i]/=b;
52     a[1]/=b;
53     while(!a[a[0]] && a[0]>1)a[0]--;
54 }
55 void gjdprint(int a[])
56 {
57     int i;
58     printf("%d",a[a[0]]);
59     for(i=a[0]-1;i;i--)
60         printf("%04d",a[i]);
61     puts("");
62 }
63 int main()
64 {
65     #ifndef ONLINE_JUDGE
66 //    freopen("1.txt","r",stdin);
67 //    freopen("2.txt","w",stdout);
68     #endif
69     int i,j,k;
70     int x,y,z;
71 //    for(scanf("%d",&cass);cass;cass--)
72 //    for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
73 //    while(~scanf("%s",s+1))
74     while(~scanf("%d",&n))
75     {
76         n++;
77         a[0]=a[1]=1;
78         for(i=n+1;i<=n+n;i++)
79             gjdchengdjd(a,i);
80         for(i=2;i<=n+1;i++)
81             gjdchudjd(a,i);
82         gjdprint(a);
83     }
84     return 0;
85 }
86 /*
87 //
88 
89 //
90 */
View Code

 

转载于:https://www.cnblogs.com/Coolxxx/p/5827440.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值