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

CRASH !! (Access_Violation)
Posted by ABZee 3 May 2003 20:18
#include"stdio.h"

int main()
{

    int i,j,tmp,sum=1;
    int count[6000]={0};

//input&run
    for(i=0;i<10;i++){
        scanf("%d",&tmp);
        for(j=2;j<tmp/2;j++)
            if(tmp%j==0){
                count[j]++;
                tmp/=j;
                j=1;
            }
        count[tmp]++;
    }

    for(i=2;i<5000;i++)
        if(count[i]!=0){
            sum*=count[i]+1;
            sum%=10;
        }


//output
    printf("%d",sum);

    return(0);
}

What's wrong with mine?
OK, It's my false. Too small array size.
Posted by ABZee 3 May 2003 23:08
> #include"stdio.h"
>
> int main()
> {
>
>     int i,j,tmp,sum=1;
>     int count[6000]={0};  <<< here
>
> //input&run
>     for(i=0;i<10;i++){
>         scanf("%d",&tmp);
>         for(j=2;j<tmp/2;j++)
>             if(tmp%j==0){
>                 count[j]++;
>                 tmp/=j;
>                 j=1;
>             }
>         count[tmp]++;
>     }
>
>     for(i=2;i<5000;i++)   <<and here
>         if(count[i]!=0){
>             sum*=count[i]+1;
>             sum%=10;
>         }
>
>
> //output
>     printf("%d",sum);
>
>     return(0);
> }
>
> What's wrong with mine?