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 zhangjb at 2005-03-21 12:10:44 on Problem 1455
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Times
{
	long rTime;
	long lTime;
	Times()  { rTime = lTime =0; }
};

void main()
{
	int n;  cin >> n;
	vector<int> input(n);
	for (int i=0; i<input.size(); i++)
		cin >> input[i];
	int persons = *(max_element(input.begin(), input.end()));

	vector<Times> times(persons+1);
	times[2].lTime = 1;
	for (n=3; n<times.size(); n++)
	{
		int a = n/2, b = n-a;
		times[n].rTime = times[a].lTime+times[b].lTime;
		times[n].lTime = a*b+times[n].rTime;
	}
	for (i=0; i<input.size(); i++)
		cout << times[input[i]].rTime << endl;
}

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