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

Metallllllll How to make my solution so fast on C++? [4] // Problem 1001. Reverse Root 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]);
    }

}
KirillB(Arkhangelsk - PomorSU) Re: How to make my solution so fast on C++? [2] // Problem 1001. Reverse Root 31 Jan 2007 02:00
Use block i/o but better use Pascal:))

Edited by author 31.01.2007 02:08
Romko [Lviv NU] Re: How to make my solution so fast on C++? [1] // Problem 1001. Reverse Root 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
KirillB(Arkhangelsk - PomorSU) Re: How to make my solution so fast on C++? // Problem 1001. Reverse Root 31 Jan 2007 02:59
Special optimization is needed on Pascal for 0.125
You solution on Pascal is very good
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