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

我刚学!!!贴个代码来玩玩0ms

Posted by jianxiawzx at 2010-08-04 14:34:24 on Problem 1338
typedef struct {int xuhao;long a;} ABC;
ABC abc[1500];
long x1,x2,x3;

int min(int a,int b,int c)
{
	if(a>=b)
		a=b;
	if(a>=c)
		a=c;
	return a;
}
int search(int x)
{
	int i,k;
	for(i=0;i<=x;i++)
	{
		if(abc[i].a*5<=abc[x].a)
			continue;
		else
		{
			k=i;
			x1=5*abc[i].a;
		}
		break;
	}
    for(i=k;i<=x;i++)
	{
		if(abc[i].a*3<=abc[x].a)
			continue;
		else
		{
			k=i;
			x2=3*abc[i].a;
		}
		break;
	}
	for(i=k;i<=x;i++)
	{
		if(abc[i].a*2<=abc[x].a)
			continue;
		else
		{
			k=i;
			x3=2*abc[i].a;
		}
		break;
	}
	return min(x1,x2,x3);
}
int main()
{
	int i,n,k=1;
    abc[0].xuhao=1;
    abc[0].a=1;
    abc[1].xuhao=2;
    abc[1].a=2;
	while(k==1)
	{
	    scanf("%d",&n);
	    if(n!=0)
		{
	        for(i=2;i<n;i++)
			{
		        abc[i].xuhao=i+1;
		        abc[i].a=search(i-1);
			}
	        printf("%ld\n",abc[n-1].a);
		}
		else k=0;
	}
	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