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

Show all messages Hide all messages

Why is WA for Test 9? Pls. Help me. logic 21 Aug 2008 13:36
#include<stdio.h>
#include<math.h>
int main()
{
     double a[100000];
     signed long int i = 0;
     while (scanf("%lf", &a[i]) != EOF)
     {
         i++;
     }
     i--;
     while ( i >= 0)
     {
         printf("%.4lf\n",sqrt(a[i]));
         i--;
     }
     return ;
}
Re: Why is WA for Test 9? Pls. Help me. Danshin Anton (LIOD Orenburg) 14 Sep 2008 14:30
!!!!!EXTENDED for Pascal!!!!!!
!!!!!LONG DOUBLE for C++!!!!!!
Re: Why is WA for Test 9? Pls. Help me. nikonoff (ONPU) 22 Sep 2008 19:02
try this:
double a [128*1024]
Re: Why is WA for Test 9? Pls. Help me. Aleksa_Markoni 23 Nov 2008 01:32
use dinamic memory try
double *a = (double *) malloc (sizeof(double)*128*1024);
and when you done before return
free (a);
thats all :)
Aleksa_Markoni, thank you!
Re: Why is WA for Test 9? Pls. Help me. yangqiang 31 Mar 2009 07:12
Could you tell me why it should use dinamic memory ?
Thank you!
Re: Why is WA for Test 9? Pls. Help me. chinagdjdlyd 6 Oct 2009 08:40
There is no need to use dinamic memory ...
Just make sure that your array is large enough.
But I wonder why the result I get is TLE ...
this is my code:
#include<stdio.h>
#include<string.h>
#include<math.h>

double a[100010];//make it larger and then I got AC

int main()
{
    int k=0;
    while(scanf("%lf",&a[k])!=EOF)k++;
    while(k)
        printf("%.4lf\n",sqrt(a[--k]));

    return 0;
}
Aleksa_Markoni wrote 23 November 2008 01:32
use dinamic memory try
double *a = (double *) malloc (sizeof(double)*128*1024);
and when you done before return
free (a);
thats all :)


Edited by author 21.10.2009 00:40
Re: Why is WA for Test 9? Pls. Help me. rachelwang 4 Mar 2010 12:59
while your program submit
it replies Time limit exceeded
for what reason?