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 flyingfish at 2005-08-29 17:02:45 on Problem 2591
In Reply To:帮忙改一下 Posted by:jxc2004 at 2005-08-29 16:41:16
#include<iostream>
using namespace std;
int num[10000000];
int main()
{
	int i,two,three,t1,t2,n;
	two=three=0;
	num[0]=1;
	for(i=1;i<10000000;i++)
	{
		t1=2*num[two]+1;
		t2=3*num[three]+1;
		if(t1<t2)
		{
			num[i]=t1;
			two++;
		}
		else if(t1>t2)
		{
			num[i]=t2;
			three++;
		}
		else
		{
			num[i]=t1;
			three++;
			two++;
		}
	}
	while(cin>>n)
		cout<<num[n-1]<<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