您的位置:首页 > 其它

HDU - 4828 多写几组数就好了;

2018-01-30 20:44 148 查看
这题翻译加理解过来是这样的

卡兰特数列:递推公式:h(n)=h(n-1)*(4*n-2)/(n+1);

然后要 注意 千万注意  %d和%lld 就tmd这玩意劳资改了一个多小时日狗了

然后下面是ac的代码;#include <algorithm>
#include <cstdio>
#include <iostream>
#define max 1000000
using namespace std;
typedef long long ll;
ll p=1000000007;
ll a[1000005];
ll quick_pow(ll a,ll b) //快速幂;
{
ll ans=1;
while(b)
{
if(b&1) ans=(ans*a)%p;
b>>=1;
a=(a*a)%p;
}
return ans;
}
int main()
{
a[0]=1;
for(ll i=1;i<=max;i++)
a[i]=((a[i-1]*(4*i-2)%p)*quick_pow(i+1,p-2))%p;
int t;
scanf("%d",&t);
int q=1;
while(t--)
{
int n;
scanf("%d",&n);
printf("Case #%d:\n%lld\n",q++,a
);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  acm