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:用dp怎么做的?

Posted by dhl23 at 2008-10-11 00:31:57 on Problem 1953
In Reply To:用dp怎么做的? Posted by:goodpeter at 2007-08-20 00:38:12
#include<iostream>
using namespace std;

int main()
{
	int t,count=0,array[50][2],i,n;
	array[1][0]=1;
	array[1][1]=1;
	for(i=2;i<=45;i++)
	{
		array[i][0]=array[i-1][1]+array[i-1][0];
		array[i][1]=array[i-1][0];
	}
	cin>>t;
	while(t--)
	{
		count++;
		cin>>n;
		cout<<"Scenario #"<<count<<":"<<endl;
		cout<<array[n][0]+array[n][1]<<endl;
		cout<<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