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

请问大牛们,这样算记忆化搜索吗?

Posted by yangover at 2008-05-27 23:05:12 on Problem 2696
#include<iostream>
using namespace std;
int run(int a,int b);
int a,b,c,d,e,f,g,h;
int p[2000];
int Q(int i)
{	
	if(p[i]==1)
		return Q(i);
	if(i==0)
	{
		return a;
		p[i]=1;
	}
	if(i==1)
	{
		return b;
		p[i]==1;
	}
	if(i==2)
	{
		return c;
		p[i]=1;
	}
	if((i>=3)&&(i%2==1)&&(p[i]==0))
	{
		return run((d*Q(i-1)+e*Q(i-2)-f*Q(i-3)),g);
		p[i]=1;
	}
	if((i>=3)&&(i%2==0)&&(p[i]==0))
	{
		return run((f*Q(i-1)-d*Q(i-2)+e*Q(i-3)),h);
		p[i]=1;
	}

}
int run(int a,int b)
{
	if(a>=0) return a%b;
	else return (b-(-a%b));
}
int main()
{
	
  int n,i,j,sum;
	cin>>n;
	memset(p,0,sizeof(p));
	for(i=0;i<n;i++)
	{
		cin>>a>>b>>c>>d>>e>>f>>g>>h>>j;
		sum=Q(j);
		cout<<sum<<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