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 08063102 at 2011-07-28 11:47:16 on Problem 1595
#include<stdio.h>
#include<math.h>
main()
{
	int m,n,i,j,k,h,x;
	int a[1101];
	while(scanf("%d%d",&m,&n)!=EOF)
	{
		printf("%d %d:",m,n);
		k=0;
	
		for(i=1;i<=m;i++)
		{
		  x=sqrt((double)i);
		  for(j=2;j<=x;j++)
	    	{
			  if(i%j==0)
			  break;
		    }
			if(j>x)
			 {
 			   	a[k]=i;
 			   	k++;
 			 }	
		}
		 if(m%2!=0)
		 {
		 	n=2*n-1; 	
		 }	
		else
		 {
			n=2*n;	
		 }	
		if(n/2>k||n>k)
		{
		   for(j=0;j<k;j++)
		   printf(" %d",a[j]);
		}
		else if(n==2&&k<=3)
		 printf(" %d",a[n-1]);
		
		else
		{
		 h=(k-n)/2;
	     for(j=h;j<h+n;j++)
	     {
   		   printf(" %d",a[j]);
   	     }	
		}  
		  printf("\n\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