INTEST: Getting rte

My code is :

main(void)
{ 
    unsigned long int n,div,out=0;
    long long num;
    int i;
    scanf("%lu%lu",&n,&div);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&num);
        if(num<div)
        continue;

        else
        if(num%div == 0)
        out++;
    }

    printf("%d",out);

}

I am not sure as to why this results in a Runtime Error.

Any help would be highly appreciated.

1 Like

your out is declared as an unsigned long, but you print it as an int. moreover, it seems, regarding the problem statement, that storing num in a long long is not really necessary. an unsigned long should be enough. please tell us if it solves your problem :slight_smile:

1 Like

In C language you need to have a return 0 when exiting from main. FAQ | CodeChef

2 Likes

Your code is optimized except for long long for num.
People whose execution is lesser, they optimize the I/O. ie they use block reading and their processing so that less I/O is performed. Generally without I/O optimized code passes in codechef, I/O optimization only reduces the execution time.

The problem persists, I corrected the points mentioned by you but still it shows Runtime Error.

Thanks, it worked this time.
But the time of execution was 5.55sec while some other solutions worked in .48sec

So can you help me to optimize the solution…
Thanks a lot.