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 1048. Superlong Sums

Why i get WA? Can anyone tell me why?
Posted by Matei Alexandru 3 Sep 2002 03:43
#include <stdio.h>
#include <stdlib.h>

#define ONLINE_CONTEST
void main()
{
    long n;
    long nr;
    int i, x, y, ant, first = 1;
#ifndef ONLINE_CONTEST
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    scanf("%ld", &n);
    nr  = 0;
    for(i = 0; i < n; i++)
    {
        scanf("%d%d", &x, &y);
        x = x + y;
        if(first)
        {
            first = 0;
            ant = x;
        }
        else if(x < 9)
        {
            printf("%d", ant);
            for(y = 0; y < nr;y++)
            {
                printf("9");
            }
            ant = x;
            nr=0;
        }
        else if(x == 9)
        {
            nr++;
        }
        else if(x > 9)
        {
            printf("%d", ant+1);
            for(y = 0; y < nr; y++)
            {
                printf("0");
            }
            ant = x % 10;
            nr = 0;
        }
    }
    if(!first)
        printf("%d", ant);
}