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 1413. Mars Jumper

Crash (access violation)
Posted by Hayk Blrtsyan 31 Aug 2007 16:33
I do evrything, but I get Crash (access violation)on test6

Here is my code in C++
Pleaz HEEEEELP me !!!

#include <stdio.h>
#include <string.h>
#include <math.h>
#define d sqrt((double)2)/2

double dx[] = { 0,-d,0,d,-1,0,1,-d,0,d };
double dy[] = { 0,-d,-1,-d,0,0,0,d,1,d };
double x, y;
int n, i;
char s[250005];

int main()
{
    scanf("%s", &s);
    n = strlen(s);
    for(i = 0; i < n; i++)
    {
        if(s[i] == '0' || s[i] == 13)    break;
        x += dx[s[i]-48];
        y += dy[s[i]-48];
    }

    printf("%.11lf %.11lf\n", x, y);

    return 0;
}

Edited by author 31.08.2007 16:37
Re: Crash (access violation)
Posted by Lomir 31 Aug 2007 17:35
"Not more than 1000000 digits from 0 to 9."
Now count number of zeros here. It is 1kk (1 million).

And your array is only 250005. Where have you found this number? It's defenetely not enough.