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 sunwen at 2007-09-22 10:17:23 on Problem 2247
#include<stdio.h>
int t=0,a[5842]={1};
void f(int m)
{
	int n;
	n=m;
	if(t>5500)
		return;
	a[t]=n;
	t++;
	if(n<=1000000000)f(2*n);
	if(n<=666666666)f(3*n);
	if(n<=400000000)f(5*n);
	if(n<=285714285)f(7*n);
}
int main()
{
	int n,x;
	f(1);
	for(int i=0;i<5482;i++)
	{
		for(int x,j=i+1;j<5482;j++)
		{
			if(a[i]<a[j])
			{
				x=a[i];
				a[i]=a[j];
				a[j]=x;
			}
		}
	}
	while(scanf("%d",&n)&&n!=0)
		printf("%d\n",a[n]);
}

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