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

How can we get 0.031 or 0.046?
Posted by ONU_1785 19 Jan 2012 20:08
I got 0.218, 104Kb with this code:

#include <cstdio>
#include <cstdlib>



int main()
{
     char str[8];
     gets (str);
     int n=atoi(str);

    char s,sum=0;

    int count=0;

    while (n)
    {
        gets(str);

        s=str[0]+str[2];

        if (s==105) {putchar(57); --n;}
        else {sum=s; --n; break; }
    }

    if (!n) return 0;


    for (int i=0; i<n; ++i)
    {
        gets(str);

        s=str[0]+str[2];


        if (s==105) {++count;}
        else
        {


            if (s<=104)
            {

                putchar(sum-48);

                for (; count>0; --count)
                    putchar(57);

                sum=s;

            }
            else
            {

                if (s>=106)
                {

                    putchar(sum-47);

                    for (; count>0; --count)
                    putchar(48);

                sum=s-10;

                }
            }
        }


    }

    if (s==105)
    {

            putchar(sum-48);

        for (; count>0; --count)
                putchar(57);

    }
    else
        if (sum)

            (s>=106)?putchar(s-58):putchar(s-48);
}

Could anyone tell me what should i do to make it faster?