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 |
AC 好辛苦,问了几个人都没回复,自己慢慢找到一个bug不用 unsigned 也可以过 特殊处理边界,用减法 贴一小段核心代码 int Start, Size = U - L + 1, i = 1; int p = primes[i], QRT = (int)sqrt(U) + 1; memset(LU,true,Size + 80); while (p <= QRT) { Start = ( p - (L - 1) % p ) - 1 if(L < p*2 - Start);//这里不用加法判断,否则WA Start += p; if (Start % 2 == 1) Start += p; while (Start < Size) { if(LU[Start] == true) LU[Start] = false; Start += p*2; } p = primes[++i]; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator