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 ryzasia at 2010-03-15 22:11:05 on Problem 1953
In Reply To:超时啊!!!!!!!!!那位大虾帮帮,看看出了什么问题 Posted by:19850317 at 2007-08-28 17:27:45
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <list>
#include <map>
#include <set>
using namespace std;

long array[50][2];


class POJ     
{
  public:
  int POJMethod()
  {
    array[1][1] = 1;
    array[1][0] = 1;
    for(int i = 2;i<=49;++i)
    {
      array[i][0] = array[i-1][0] + array[i-1][1];
      array[i][1] = array[i-1][0];        
    }
    return 0;
  }
};


int main()
{     
    int n,Scenario;
    cin>>n;
    int temp = n;
    POJ  test;
    test.POJMethod();
    
    while(temp--)
    {
      cin>>Scenario;
      printf("Scenario #%d:\n%d\n\n",n-temp,array[Scenario][1]+array[Scenario][0]);

    }

    system("pause");
    return 0;
};


比较简单的DP,希望能对您有帮助

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