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

统计的方法很重要,似乎不用二分法

Posted by pkkj at 2008-07-07 13:13:26 on Problem 3511
在进行素数筛选的时候,对于循环变量i,用数组分别揭露下从0到i之间有多少个素数, 有多少个符合条件的素数.分别存在prime_num[]和fprime_num[]之中.(这两个数组开大一点不怕,开到一百万).
之后从程序中读入L和U.稍作整理,我们要输出的就是prime_num[U] - prime_num[L-1]和fprime_num[U]-fprime_num[L-1].因为prime_num[U] - prime_num[L-1]就是[L,U]区间之中素数的个数.

注意,题目会给负数
另外,2虽然不是4p+1,但是2 = 1^2 + 1^2,所以2也是.题目没有说一定要是奇素数,只是说:can be expressed as a sum of squares.

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