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:唉,谁能告诉我为什么wa了??快吐血了~~~

Posted by yuhuafx at 2008-08-18 03:14:59 on Problem 3518
In Reply To:唉,谁能告诉我为什么wa了??快吐血了~~~ Posted by:chqch172443 at 2008-07-01 16:01:37
> 测试数据都对,连最大那个质数都对,为什么就是wa了??
> 
> #include<stdio.h>
> #include<math.h>
> int prime(n)
> {int k,i;
> if(n>10000) k=(int)(sqrt(n/10000)*100);
> else k=(int)sqrt(n);
> for(i=2;i<=k;i++)
>    if(n%i==0) break;
>    if(i>k) return 1;
>    else return 0;
> }
> void main()
> {int n,t,s;
> while(scanf("%d",&n))
>     {if(n==0) break;
>      if(prime(n)) printf("0\n");
>      else
>          {for(t=n-1;;t--)
>              if(prime(t)) break;
>          for(s=n+1;;s++)
>             if(prime(s)) break;
> 	 printf("%d\n",s-t);
>         }
>      }
> }


边缘数据,、n = 1,print 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