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:简单易懂~

Posted by Eov_Second at 2016-11-26 19:11:54 on Problem 2262
In Reply To:简单易懂~ Posted by:yueyibo at 2016-11-23 20:55:52
> http://blog.csdn.net/luckcircle/article/details/53311457
> 欢迎提出更优算法~
这个筛效率可以优化
			for(int j=i+i;j<=MAX;j=j+i){
				isprime[j]=false;
			}

首先偶数用不着筛,只筛奇数就可以
j = i*i开始, i+i, 3i, 5i...前面肯定筛过了,j=j+i也可以改成j=j+2*i,

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