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 |
什么都不多说,贴代码#include<stdio.h> #include<math.h> int find (int x); main() { int a,b,i,k; while(scanf("%d %d",&a,&b)!=EOF&&a,b!=-1) { k=0; for(i=a;i<=b;i++) { if(find(i)==1) k++; } printf("%d\n",k); } } int find (int x) { int i,flag=1; if(x<2) { flag=0; } else if(x==2||x==3) flag=1; else { for(i=2;i<=sqrt(x);i++) { if(x%i==0) { flag=0; break; } } } return flag; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator