http://acm.hdu.edu.cn/showproblem.php?pid=2065
Problem Description
医学界发现的新病毒因其蔓延速度和Internet上传播的"红色病毒"不相上下,被称为"红色病毒",经研究发现,该病毒及其变种的DNA的一条单链中,胞嘧啶,腺嘧啶均是成对出现的。
现在有一长度为N的字符串,满足一下条件:
(1) 字符串仅由A,B,C,D四个字母组成;
(2) A出现偶数次(也可以不出现);
(3) C出现偶数次(也可以不出现);
计算满足条件的字符串个数.
当N=2时,所有满足条件的字符串有如下6个:BB,BD,DB,DD,AA,CC.
由于这个数据肯能非常庞大,你只要给出最后两位数字即可.
现在有一长度为N的字符串,满足一下条件:
(1) 字符串仅由A,B,C,D四个字母组成;
(2) A出现偶数次(也可以不出现);
(3) C出现偶数次(也可以不出现);
计算满足条件的字符串个数.
当N=2时,所有满足条件的字符串有如下6个:BB,BD,DB,DD,AA,CC.
由于这个数据肯能非常庞大,你只要给出最后两位数字即可.
Input
每组输入的第一行是一个整数T,表示测试实例的个数,下面是T行数据,每行一个整数N(1<=N<2^64),当T=0时结束.
Output
对于每个测试实例,输出字符串个数的最后两位,每组输出后跟一个空行.
Sample Input
4 1 4 20 11 3 14 24 6 0
Sample Output
Case 1: 2 Case 2: 72 Case 3: 32 Case 4: 0 Case 1: 56 Case 2: 72 Case 3: 56
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
const int mod=100;
int key1[]=
{
2,6,20,72,72,56
};
int key[]=
{
60,12,92,56,0,52,12,56,40,92,32,56,80,32,52,56,20,72,72,56
};
int main()
{
//freopen("1.txt","r",stdin);
int T;
while(scanf("%d",&T),T)
{
for(int casetime=1;casetime<=T;casetime++)
{
printf("Case %d: ",casetime);
unsigned long long int n;
cin>>n;
if(n<=6) cout<<key1[n-1]<<'\n';
else
{
n-=6;
n%=20;
if(n==0) n=20;
cout<<key[n-1]<<'\n';
}
}
printf("\n");
}
return 0;
}
#include<cstdio>
#include<math.h>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long int ll;
ll f(int n)
{
if(n<2) return 1;
ll ret=1;
for(int i=1;i<=n;i++)
{
ret*=(i);
}
return ret;
}
ll C(int n,int m)
{
freopen("C:\\Users\\5201\\Desktop\\out.txt","w",stdout);
return f(n)/f(m)/f(n-m);
//ll a=1;
// if(m==0)
// return 1;
// for(ll i=1;i<=m;i++)
// {
// a=a*(n-i+1);
// a=a/i;
// }
// return a;
}
ll mypow(ll a,ll b)
{
ll ret=1;
for(ll i=1;i<=b;i++)
{
ret*=a;
ret%=100;
}
return ret;
}
int main()
{
//cout<< mypow(2,4)+4+6*2*4+4<<endl;
for(ll n=1;n<110;n++)
{
ll ans=mypow(2,n);
ll t=n/2;
for(ll i=1;i<=t;i++)
{
//ll t1=mypow(2,c(n,2*i) );
//ll t1=c(n,2*i)*mypow(2,i) ;
ll t1=C(n,2*i);
ll t3=0;
ll t2=mypow(2,n-2*i);
for(ll j=0;j<=i;j++)
{
ll tt=C(2*i,2*j);
t3+=tt;
}
t1%=100,t2%=100,t3%=100;
ans+= t1*t2*t3;
}
cout<<n<<" "<<ans%100<<endl;
}
return 0;
}