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:SB题目……详见代码

Posted by huicpc39 at 2011-11-28 21:40:50 on Problem 3978 and last updated at 2011-11-28 21:52:24
In Reply To:SB题目……详见代码 Posted by:buaabarty at 2011-07-21 15:32:26
#include <stdio.h>
int p[50001]={0};
void sieve(){
int i,j,k;
for(i=1;i<159;++i)
   if(!p[i])
     for(k=(i<<1)+1,j=i*k+i;j<50000;j+=k)
      p[j]=1;
for(p[0]=i=1;i<50001;++i)p[i]=p[i-1]+1-p[i];}

int main(){
int a,b;
sieve();
while(scanf("%d%d",&a,&b),a!=-1||b!=-1)
printf("%d\n",(b<2?0:p[(b-1)>>1])-(a<3?0:p[(a>>1)-1]));
return 0;}

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