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:WHY WRONG ANSWER?????

Posted by killuax at 2008-05-24 01:48:03 on Problem 2262
In Reply To:WHY WRONG ANSWER????? Posted by:rockzero at 2008-02-16 21:14:15
> #include <stdio.h>
> 
> char flag[1000001]={'\0'};
> void creat()
> {
>      unsigned long i,j;
>      for(i=2;i<1000001;i++)
>      {if(flag[i]=='\0')
>      {for(j=i;j*i<1000001;j++)
>      flag[i*j]='1';}}
> }
> int main()
> {
>       unsigned long num,k;
>     
>     
>     creat();
>   
>     
>     scanf("%lu",&num);
>     while(num>0)
>     {
>                 for(k=3;k<=num/2;k++)
>                 {
>                                       if((flag[k]=='\0')&&(flag[num-k]=='\0'))
>                                       {printf("%lu = %lu + %lu\n",num,k,num-k);
>                                       break;}
>                 }
>                 if(k>num/2)
>                 printf("Goldbach's conjecture is wrong.");
>                 scanf("%lu",&num);
>     }
>     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