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 bakey at 2005-08-12 22:56:40 on Problem 2552
In Reply To:怎么模拟? 我每次把剩下的数构成一个新的数组,可以节省很多运算量!但是还是TLE!但是在我电脑上感觉不出来很慢呀!输入3000立即就出来结果了!(内有程序,牛人帮下忙!) Posted by:ook at 2005-08-12 21:45:27
> #include "stdio.h"
> #include "memory.h"
> int a[34000];
> int n;
> int main()
> {
> 	int i,k,c,len,len1,p;
> 	while(1)
> 	{
> 		scanf("%d",&n);
> 		if(n==0) break;
> 		for(i=0;i<34000;i++)
> 			a[i]=i+2;
>         c=0;  len1=34000;
> 	    while(1)
> 		{
> 			c++;
> 			if(c==n) break;
> 			k=0; p=a[0];i=0;
> 			while(k<len1)
> 			{
> 				if(k%p!=0) 
> 				{
> 					a[i++]=a[k];
> 				}
> 				k++;
> 			}
> 			len1=i;
> 		}
> 		printf("%d\n",a[0]);
> 	}
> return 1;
> }

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