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

AC 好辛苦,问了几个人都没回复,自己慢慢找到一个bug

Posted by gemenhao at 2006-04-30 02:02:37 on Problem 2689
不用 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:
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