problem url: http://acm.timus.ru/problem.aspx?space=1&num=1001
Use static Array to hold all the square root values and print them all:
the AC result is not so good: 0.42s and 12xxKB, maybe I should implement the sqrt myself?
#include
<
cstdio
>
#include < iostream >
#include < cmath >
using namespace std;
#define MAXNUM 700000
double dList[MAXNUM];
void main()
{
int i = 0 ;
double dCur = 0.0 ;
while (scanf( " %lf " , & dCur) != EOF)
{
dList[i] = sqrt(dCur);
++ i;
}
while (i > 0 )
{
printf( " %.4f " , dList[i - 1 ]);
-- i;
}
}
#include < iostream >
#include < cmath >
using namespace std;
#define MAXNUM 700000
double dList[MAXNUM];
void main()
{
int i = 0 ;
double dCur = 0.0 ;
while (scanf( " %lf " , & dCur) != EOF)
{
dList[i] = sqrt(dCur);
++ i;
}
while (i > 0 )
{
printf( " %.4f " , dList[i - 1 ]);
-- i;
}
}