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

How to make my solution so fast on C++?
Posted by Metallllllll 31 Jan 2007 01:01
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

void main()
{
    int i = 0;
        int k;
    double b;
    double *a = (double*)malloc(sizeof(double)*1000000);
    while(scanf("%lf",&b) != EOF)
    {
        a[i] = sqrt(b);
        i++;
    }
    for(k = i - 1;k >= 0; k--)
    {
        printf("%.4lf\n",a[k]);
    }

}
Re: How to make my solution so fast on C++?
Posted by KIRILL(ArcSTU) 31 Jan 2007 02:00
Use block i/o but better use Pascal:))

Edited by author 31.01.2007 02:08
Re: How to make my solution so fast on C++?
Posted by Roma Labish[Lviv NU] 31 Jan 2007 02:11
I don't understand what did you say... What does it mean block i/o?
P.S. The same solution on Pascal work 0.125 sec
Re: How to make my solution so fast on C++?
Posted by KIRILL(ArcSTU) 31 Jan 2007 02:59
Special optimization is needed on Pascal for 0.125
You solution on Pascal is very good
Re: How to make my solution so fast on C++?
Posted by dibrov.bor 31 Jan 2007 14:18
why you save sqrt () of value?
you can save value b like __int64 and later print sqrt() of it
I suppose it get less memory that double