topic
Thinking
Generating function directly up hate
We first consider selecting these letters, the only option was considered different letters different schemes
For \ (A \) and \ (C \)
\(G(x)=\sum_{i=0}^{\infty}\frac{1}{(2i)!}x^{2i}\)
For \ (B \) and \ (D \)
\(F(x)=\sum_{i=0}^{\infty}\frac{1}{i!}x^i\)
After written, these two forms is a routine of things
\(G(x)=\frac{e^x+e^{-x}}{2}\\F(x)=e^x\)
They will roll up
\(\begin{aligned}H(x)&=G^2(x)F^2(x)\\&=(\frac{e^x+e^{-x}}{2})^2*e^{2x}\\&=\frac{e^{4x}+2e^{2x}+1}{4}\\&=\frac{\sum_{i=0}^{\infty}\frac{1}{i!}(4x)^i+2*\sum_{i=0}^{\infty}\frac{1}{i!}(2x)^i+1}{4}\end{aligned}\)
We just need \ (x ^ n \) coefficient, do not forget our definition of the generating function, but also need to look at the whole arrangement
\ (Years = n! \ Frac {\ frac {4 ^ n} {n!} + 2 * \ frac {2 ^ n} {n!}} {4} = \ frac {4 ^ n + 2 * 2 ^ n} {4} = 4 ^ {n-1} + 2 ^ {n-1} \)
Code
#include<iostream>
using namespace std;
const int mod=100;
int qkpow(int a,long long b)
{
if(b==0)
return 1;
if(b==1)
return a;
int t=qkpow(a,b/2);
t=(t*t)%mod;
if(b%2==1)
t=(t*a)%mod;
return t;
}
int t;
long long n;
int main()
{
ios::sync_with_stdio(false);
while(cin>>t)
{
if(!t)
break;
for(int i=1;i<=t;i++)
{
cin>>n;
cout<<"Case "<<i<<": "<<(qkpow(4,n-1)+qkpow(2,n-1))%mod<<'\n';
}
cout<<'\n';
}
return 0;
}