hdu 2065 "紅色病毒"問題

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.
由於這個數據肯能非常龐大,你只要給出最後兩位數字即可.
 

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;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章