Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

Incorrect output for larger test cases

$
0
0

I am trying to solve this problem : https://icpc.kattis.com/problems/different

Here's my code :

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main (void)
{
    unsigned long long int x, y, z;
    while (scanf("%llu%llu", &x, &y) != EOF)
    {
        printf ("%llu\n", abs (x - y) );
        if (scanf ("%llu%llu", &x, &y) == EOF)
        break;
        printf ("%llu\n", abs (x - y) );
    }

    return 0;
}

It gives correct output for smaller test cases but fails for the larger ones. I am using GCC 4.8.1 on Windows XP 32 BIT Edition.

Input :

1 2 232 23 23 3 456 6 4 566 45 5 45 5 666 4 34 4343 34 34 34 5646 5645 32423 23423 32423 0 5 65 0 10 12 1871293781758123 72784 1 9223372036854775807

Output :

1 209 20 450 562 40 40 662 4309 0 5612 26778 9000 5 65 2 1994345381 2

AFAIK unsigned long long int should be enough for handling 20 digit integers.

Also, is there a way for generating large number of test cases to test my code instead of manually typing them?


Viewing all articles
Browse latest Browse all 40121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>