题面
题意:有A,B,C,D 4种字母
A,B只能用偶数个
问组成长为n的串的方案数
可重组合问题用指数生成函数
无限制的指数生成函数为
ex
e
x
只能选偶数的指数生成函数为
(ex+e−x)/2
(
e
x
+
e
−
x
)
/
2
乘起来为 e4x+2e2x+14 e 4 x + 2 e 2 x + 1 4
泰勒展开,第n项系数大概是 4n−1+2n−1 4 n − 1 + 2 n − 1
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define mmst(a, b) memset(a, b, sizeof(a))
#define mmcp(a, b) memcpy(a, b, sizeof(b))
typedef unsigned long long LL;
int T;
LL n;
int cheng(int a,LL b)
{
int res=1;
for(;b;b>>=1,a=a*a%100)
if(b&1)
res=res*a%100;
return res;
}
int main()
{
while(1)
{
scanf("%d",&T);
if(!T)
break;
int kana=0;
while(T--)
{
kana++;
scanf("%llu",&n);
printf("Case %d: %d\n",kana,(cheng(2,n-1)+cheng(4,n-1))%100);
}
printf("\n");
}
return 0;
}
我决定再也不卸炉石
除非我手机装了炉石