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

提交n次了都wa,哪位高手来帮下小弟?郁闷啊!

Posted by HG at 2009-01-11 22:46:50 on Problem 1595
#include<stdio.h>
int main()
{
	int prime[500]={1,2,0},i,i1,i2,k,index=2,input1,input2;
	for(i=3;i<1500;i++)
	{
		k=0;
		for(i1=1;i1<index;i1++){if(i%prime[i1]==0){k++;break;}}
		if(!k){prime[index++]=i;}
	}
	while(scanf("%d %d",&input1,&input2)!=EOF)
	{
		for(i=0;prime[i]<input1;i++);
		if(prime[i]=input1)i++;
		if(i%2==0)
		{
			i1=(i/2)-input2;
			i2=(i/2)+input2-1;
		}
		else
		{
			i1=((i-1)/2)-input2+1;
			i2=((i-1)/2)+input2-1;
		}
		if(i1<0)i1=0;
		if(i2>=i)i2=i-1;
		printf("%d %d:",input1,input2);
		for(i=i1;i<=i2;i++){printf(" %d",prime[i]);}
		printf("\n\n");
	}
	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