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

不是简单的多项式乘除吗。怎么wa了n次,有什么陷阱???高手帮忙看看!!

Posted by bbskill at 2004-04-16 22:24:13 on Problem 1060
#include <iostream.h>
#include <memory.h>
int main()
{
	int fx[1005];
	int gx[1005];
	int fxgx[3000];
	int hx[2000];
	int f,g,h;
	int test,i,s;
	cin>>test;
	while(test-->0)
	{
		memset(fxgx,0,3000);
		cin>>f;
		for(i=f-1;i>=0;i--)cin>>fx[i];
		cin>>g;
		for(i=g-1;i>=0;i--)cin>>gx[i];
		cin>>h;
		for(i=h-1;i>=0;i--)cin>>hx[i];
		for(i=0;i<g;i++)
		{
			if(gx[i]!=0)
				for(s=0;s<f;s++)
					if(fx[s]!=0)
						fxgx[i+s]=(fxgx[i+s]+1)%2;
		}
		for(i=g+f-2;i>=h-1;i--)
		{	
			if(fxgx[i]==1)
				for(s=h-1;s>=0;s--)
					fxgx[i-(h-1-s)]=(fxgx[i-(h-1-s)]+hx[s])%2;
		}
		for(i=h-1;i>=0;i--)
			if(fxgx[i]==1)break;
		if(i>=0) cout<<i+1;
		else cout<<(++i)+1;
		for(;i>=0;i--)
			cout<<" "<<fxgx[i];
		cout<<endl;
	}
	return 1;
}
/*
2
7
1 0 1 0 1 1 1
8
1 0 0 0 0 0 1 1
9
1 0 0 0 1 1 0 1 1
*/

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