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

Memory limit exceeded
Posted by Dim@N_SS47 16 Jul 2010 19:41
#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define DOUBLES_NUM 64

#define int64 long long

typedef struct list
{
    long double nums[DOUBLES_NUM];
    struct list *prev;
} list;

int main()
{
    unsigned char ind = 0;
    unsigned int64 temp;
    list *temppl, *pl = malloc(sizeof(list));
    pl->prev = NULL;

    while(scanf("%I64", &temp) != EOF)
    {
        pl->nums[ind] = sqrt((long double) temp);
        if(++ind >= DOUBLES_NUM - 1)
        {
            temppl = malloc(sizeof(list));
            temppl->prev = pl;
            pl = temppl;
            ind = 0;
        }
    }

    while(1)
    {
        while(ind--)
            printf("%.4Lf\n", pl->nums[ind]);

        if(pl->prev == NULL)
        {
            free(pl);
            break;
        }

        temppl = pl->prev;
        free(pl);
        pl = temppl;
        ind = DOUBLES_NUM;
    }

    return 0;
}

Why?
what you done?
Posted by Esssential 16 Jul 2010 23:20
these is ver simple input will like this

while(cin >> n)
{


}

and array a[1024*128]
Re: what you done?
Posted by Dim@N_SS47 17 Jul 2010 18:18
I know that reading input could be done much simpler. What I don't understand is why it uses over 16MB of memory.

Edited by author 18.07.2010 00:49