Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:我也是这样做的,老有问题......帮我看看把

Posted by rank123 at 2008-03-30 11:02:53 on Problem 1080
In Reply To:晕死了,原来是数组开小了。。。。。。。。FT to death Posted by:11119999 at 2006-08-10 14:15:49
#include <iostream>
using namespace std;
int max(int a,int b,int c)
{
	int max=a;
	if(b>max)
	max=b;
	if(c>max)
	max=c;
	return max;
}

int main()
{
	int T,lx,ly;
	int a[7][7],i,j;
	int  x[200],y[200];
	char xx,yy;
	int f[200][200];
	for(i=1;i<5;i++)
		a[i][i]=5;
	a[1][2]=a[2][1]=-1;a[1][3]=a[3][1]=-2;a[1][4]=a[4][1]=-1;a[1][5]=a[5][1]=-3;
	a[2][3]=a[3][2]=-3;a[2][4]=a[4][2]=-2;a[2][5]=a[5][2]=-4;
	a[3][4]=a[4][3]=-2;a[3][5]=a[5][3]=-2;
	a[4][5]=a[5][4]=-1;
	a[5][5]=0;

	cin>>T;
	while(T--)
	{
		cin>>lx;
		for(i=1;i<=lx;i++)
		{
		cin>>xx;
		if(xx=='A')
		x[i]=1;
		else if(xx=='C')
		x[i]=2;
		else if(xx=='G')
		x[i]=3;
		else
		x[i]=4;
		}
		
		cin>>ly;
		
		for(i=1;i<=ly;i++)
		{
		cin>>yy;
		if(yy=='A')
		y[i]=1;
		else if(yy=='C')
		y[i]=2;
		else if(yy=='G')
		y[i]=3;
		else
		y[i]=4;
		}
		
		

		f[0][0]=0;
		for(j=1;j<=ly;j++)
			f[0][i]=f[0][i-1]+a[5][y[j]];
		for(i=1;i<=lx;i++)
			f[i][0]=f[i-1][0]+a[x[i]][5];
			

			
		for(i=1;i<=lx;i++)
		for(j=1;j<=ly;j++)
		f[i][j]=max(f[i-1][j-1]+a[x[i]][y[j]],f[i][j-1]+a[5][y[j]],f[i-1][j]+a[x[i]][5]);
		cout<<f[lx][ly]<<endl;		
	}
		
   return 0; 
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator