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 xtu716 at 2007-08-12 11:11:22 on Problem 3292
#include <stdio.h>
#include <math.h>
int yi[250002];

void main()
{
	int H,out;
	int i,j,n;
	n=sqrt(250001);
	for(i=1;i<=n;i++)
	{
		if(yi[i]!=0)continue;
		for(j=i;4*i*j+i+j<=250001;j++)
		{
			if(yi[j]==0)yi[4*i*j+i+j]=1;
			else yi[4*i*j+i+j]=2;
		}
	}
	while(1)
	{
		scanf("%d",&H);
		if(0==H)break;
		out=0;
		n=(H-1)/4;
		for(i=1;i<=n;i++)
			if(yi[i]==1)out++;
		printf("%d %d\n",H,out);
	}
}

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