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

帮你改了一下,提交结果WA,你再看看,是不是没有筛选好。

Posted by bjss222 at 2007-07-28 01:17:21 on Problem 3292
In Reply To:为什么啊,我用筛选的办法,怎么还是超时~,路过的指点一下吧~!谢谢 Posted by:derness at 2007-07-27 23:34:21


#include <iostream>
#include <cmath>
using namespace std;
const int N=1000002;
struct array{
	bool disp;
	unsigned int value;
};
array a[N];

int main(void){
	__int64 i,j,index;
	int count,H;

	for(i=5;i<1000002;i+=4){ a[i].value=0; a[i].disp=false;	}

	for(i=5;i<1001;i+=4){
		for(j=5,index=i*j;index<1000002,j<(1000002/i)+1;j+=4){
			index=i*j;
			if(a[i].value==0 && !a[i].disp)	a[index].value=1;
			else{ a[index].value=0;	a[index].disp=true;	}
		}
	}

	count=0; for(i=25;i<N;i+=4){ if(a[i].value)	count++; a[i].value=count; }

	while(cin>>H,H){ cout<<H<<" "<<a[H].value<<endl;}
	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