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:ft.....不要递归阿,多明显的重叠子问题阿,用递推

Posted by woodybox at 2006-02-10 20:58:13 on Problem 1953
In Reply To:ft.....不要递归阿,多明显的重叠子问题阿,用递推 Posted by:TN at 2005-04-12 12:37:46
#include<iostream.h>
int main(){
	int m,n,v0=1,v1=1,t=1;
	cin>>m;
	for(int i=1;i<=m;i++){
		cin>>n;
		for(int j=2;j<=n;j++){
			t=v1;v1=v0;v0=t+v0;}
		cout<<"Scenario #"<<i<<':'<<endl;
		cout<<(v0+v1)<<endl<<endl;
		v0=1;v1=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