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 slwgu at 2005-08-29 12:32:03 on Problem 2591
#include <iostream.h>

int main()
{
	long s[10000000];
	long two,three;
	s[0]=1;
	two=three=0;
	long i;
	long tmp;
	for (i=1;i<10000000;i++)
	{
		s[i]=s[two]*2+1;
		tmp=s[three]*3+1;
		if (tmp<s[i]) 
		{
			s[i]=tmp;
			three++;
		}
		else
			two++;
	}
	while (cin>>i)
	{
		cout<<s[--i]<<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