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 1001. Reverse Root

1001::C::Wrong answer
Posted by Alex 9 Jun 2011 19:27
== code ==
#include <stdio.h>
#include <math.h>
#define MAXBUF 256000
#define MAXCOUNT 131072

#define MAX 1000000000000000000

#define IN 1
#define OUT 0

main()
{
    int state = OUT;
    int c, nc = 0;
    int cnt = -1;
    long dig[MAXCOUNT];
    while (((c = getchar()) != EOF)&&(nc<MAXBUF))
    {
        ++nc;
        if (isdigit(c))
        {
            if (state == OUT)
            {
                state = IN;
                dig[++cnt]=c-'0';
            }
            else
            {
                dig[cnt]=dig[cnt]*10+c-'0';
                if (dig[cnt]>MAX)
                {
                    dig[cnt]=(dig[cnt]+'0'-c)/10;
                    dig[++cnt]=c-'0';
                }
            }
        }
        else
        {
            state = OUT;
        }
    }
    for (;cnt>=0;cnt--)
        printf("%.4f\n",sqrt(dig[cnt]));
}
==code ==
Why?
Re: 1001::C::Wrong answer
Posted by hatred 9 Jul 2011 22:01
256KB != 256000B
try #define MAXBUF 256*1024