重现组队赛成辣鸡了,当时在那推f的数量,判断绝逼不超过4......xxxxxx....
orz LTX,场上推出来。
主要看的这篇博客https://blog.csdn.net/u012762625/article/details/48580167。
#include <iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int mod = 530600414;
const int maxn = 201316;
typedef long long LL;
LL num[maxn];//记录c的个数
LL pos[maxn];//记录位置和
LL len[maxn];//长度
LL c_c[maxn];//题干要求的输出
void init()
{
num[3] = 1,num[4] = 1;
pos[3] = 1,pos[4] = 3;
len[3] = 3,len[4] = 5;
c_c[3] = 0,c_c[4] = 0;
for(int i=5; i<=201314; i++)
{
num[i] = num[i-1]%mod+num[i-2]%mod;//斐波那契数列相加
num[i]%=mod;
pos[i] = pos[i-1]+pos[i-2]+len[i-2]*num[i-1]%mod;//前面的位置+后面位置+前面位置和*后面的数量
pos[i]%=mod;
len[i] = (len[i-1]+len[i-2])%mod;
c_c[i] = num[i-2]*pos[i-1]%mod+(len[i-2]*num[i-2]-pos[i-2])%mod*num[i-1]%mod+c_c[i-1]+c_c[i-2];
/*
前提:(i-2长度*i-2的c的个数 - i-2的位置和)->对后面的距离
c_c[i] = i-1的距离*i-2个数 + i-2对后面的距离 * i-1数量 + 斐波那契c_c;
*/
c_c[i]%=mod;
}
}
int main()
{
//freopen("in.txt","r",stdin);
init();
int t;
cin>>t;
for(int i=1; i<=t; i++)
{
int b;
cin>>b;
printf("Case #%d: ",i);
printf("%lld\n",c_c[b]);
}
}