考虑生成函数
令G(x)=(1+x1!+x22!+x33!+x44!⋯)2∗(1+x22!+x44!⋯)2G(x)=(1+x1!+x22!+x33!+x44!⋯)2∗(1+x22!+x44!⋯)2
考虑ex=1+x1!+x22!+x33!+x44!⋯ex=1+x1!+x22!+x33!+x44!⋯
e−x=1−x1!+x22!−x33!+x44!⋯e−x=1−x1!+x22!−x33!+x44!⋯
则G(x)=e2x+(ex−e−x2)2G(x)=e2x+(ex−e−x2)2
化简可得 G(x)=e2x∗e2x+e−2x+24=e4x+2∗e2x+14=(1+4∗x1!+16∗x22!+64∗x33!+256∗x44!⋯)+2∗(1+2∗x1!+4∗x22!+8∗x33!+16∗x44!⋯)+14=(14+x1!+4∗x22!+16∗x33!+64∗x44!⋯)+(12+x1!+2∗x22!+4∗x33!+8∗x44!⋯)+14G(x)=e2x∗e2x+e−2x+24=e4x+2∗e2x+14=(1+4∗x1!+16∗x22!+64∗x33!+256∗x44!⋯)+2∗(1+2∗x1!+4∗x22!+8∗x33!+16∗x44!⋯)+14=(14+x1!+4∗x22!+16∗x33!+64∗x44!⋯)+(12+x1!+2∗x22!+4∗x33!+8∗x44!⋯)+14
所以综上第nn项答案为
c++代码如下:
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x ; i <= y; ++ i)
#define repd(i,x,y) for(register int i = x ; i >= y; -- i)
using namespace std;
typedef long long ll;
template<typename T>inline void read(T&x)
{
char c;int sign = 1;x = 0;
do { c = getchar(); if( c == '-' ) sign = -1; }while(!isdigit(c));
do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
x *= sign;
}
const int mod = 100;
int ksm(int x,ll y)
{
int ans = 1;
while(y)
{
if(y&1) ans = ans * x %mod;
x = x*x %mod;
y >>= 1;
}
return ans;
}
int main()
{
int t; ll n;
while(true){
read(t);
if(t == 0) break;
rep(i,1,t)
{
read(n);
printf("Case %d: %d\n",i,(ksm(2,n-1)+ksm(4,n-1))%mod );
}
puts("");
}
return 0;
}