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:请各位帮忙看下,出现output limit exceed 问题

Posted by 282464586 at 2009-07-15 21:50:18 on Problem 1595
In Reply To:请各位帮忙看下,出现output limit exceed 问题 Posted by:gzxx102lsm at 2008-03-17 00:00:34
> #include<iostream>
> #include<math.h>
> using namespace std;
> int main()
> {
> 	int i,j,k,p,m,n,c,a[1101];
> 	while(1)
> 	{
> 		scanf("%d %d",&n,&c);
> 		a[0]=1;j=1;
> 		for(m=2;m<=n;m++)
> 		{
> 			k=sqrt(m);
> 			for(i=2;i<=k;i++)
> 				if(m%i==0)break;
> 				if(i>=k+1)
> 				{
> 					a[j]=m;
> 					j++;
> 					p=j;
> 				}
> 		}
> 		if(c>=p)
> 		{
> 			printf("%d %d:",n,c);
> 			for(i=0;i<p;i++)
> 				printf(" %d",a[i]);
> 			printf("\n\n");
> 		}
> 		else
> 		{
> 			if(p%2==0)
> 			{
> 				printf("%d %d:",n,c);
> 				for(i=p/2-c;i<=p/2+c-1;i++)
> 					printf(" %d",a[i]);
> 				printf("\n\n");
> 			}
> 			else
> 			{
> 				printf("%d %d:",n,c);
> 				for(i=p/2-(2*c-1)/2;i<=p/2+(2*c-1)/2;i++)
> 					printf(" %d",a[i]);
> 				printf("\n\n");
> 			}
> 		}
> 	}
> 	return 0;
> }
while(scanf("%d %d", &n, &c) != EOF)

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