ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1049. Brave Balloonists

[WA #2] why my code got WA #2 HELP!!
Posted by Luke Fang 18 Jul 2010 00:30
I dont know why my code got WA #2.
Someone help me.
Thank you.

I use sample test. The result is correct.
When I upload to Judge.
It always appear WA#2.



#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef struct{
   int number;
   int sieve_number[10000];
   int sq[10000];

}sieve;


int main(){

    int i,j,l, k,count=0,tmp,a;
    sieve p[11];
    memset( p,'\0',sizeof(p) );


     for(i = 0 ; i < 10 ; i++){
         scanf("%d\n",&p[i].number);
         if(p[i].number < 1 || p[i].number > 10000)  exit(0);
     }
/*
    for(i=0;i<10;i++)
         printf("%d\n",p[i].number);
*/



    for(k=0 ; k < 10 ; k++){
        l=0;
        for (i=1; i<=p[k].number; i++)
        {
            for (j=2; j<i; j++){
                if(i%j == 0){
                    count++;
                    goto Next;
                }

            }
            p[k].sieve_number[l]=i;
            l++;
        Next:;
        }
    }

/*
      printf("\n\n");

    for(i=0;i<10;i++){
          l=0;
          while (p[i].sieve_number[l] != 0){
               printf("%d\n",p[i].sieve_number[l]);
               l++;
          }
       printf("\n");
    }

printf("=======================\n");
*/

for( k = 0 ; k < 10 ;k++){
    tmp = p[k].number;

    for(  i=1 ;  i <= tmp  ;  i++ , l++ ){
         a = p[k].sieve_number[i];
        while(1){
              if ( a == 0 || tmp == 1 ) break;
              else if ( tmp % a == 0 ){
                   p[k].sq[i]++;
                   tmp=tmp/a;
              }
              else
                   break;
         }
        if(tmp == 0 ||  tmp == 1) break;


    }

}





    for(i=0;i<10;i++){
/*        printf("number %d\n",p[i].number); */
          j = 1;
          while (j <= p[i].number){
               if (p[i].sq[j] != 0){
              /*      printf("%d = %d\n",p[i].sieve_number[j],p[i].sq[j]);  */
                    p[10].sieve_number[j]=p[i].sieve_number[j];
                    p[10].sq[j]+=p[i].sq[j];
               }
               j++;
          }
      /* printf("\n"); */
    }

/*
j=1;
while (j < 10000){
               if (p[i].sq[j] != 0){
                   printf("%d = %d\n",p[10].sieve_number[j],p[10].sq[j]);
                }
                j++;
}

*/

a = 1;
j=1;
while (j < 10000){
               if (p[10].sq[j] != 0){
                  a *= ( (   p[10].sq[j]   )+1  );
                }
                j++;
}

if (  a >= 0 && a <= 9  )  printf("%d",a);
else  exit(0);
return 0;
}


/* http://www.manpagez.com/man/3/fmod/ */