Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:简单易懂~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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator