#include <stdio.h>
#include <stdlib.h>
inline double getDouble(FILE *f = stdin) {
double d;
scanf("%lf", &d);
return d;
}
int main() {
int n;
scanf("%d", &n);
double *d = new double[n];
for(int i=0; i<n; ++i) {
d[i] = getDouble();
}
for(int i=0; i<n; ++i) {
printf("%.5lf\n", d[i]);
}
return 0;
}
Edit: It can indeed be some faster as this, I estimate the following to be 2 to 3 times as fast, it will pass your input, but takes quite some assumptions, no guarantees outside the test sample :)
inline double getDouble(FILE *f = stdin) {
char ch;
bool seen = false;
bool sign = false;
char values[10];
double result =0.;
bool beforeDot = true;
int beforeLength = 0;
double multiplier;
while((ch = getc(stdin)) != EOF) {
if(ch == '-') {
sign = true;
continue;
}
if(ch == ' ' || ch == '\n') {
if(seen) break;
continue;
}
if(ch == '.') {
beforeDot = false;
multiplier = 1.;
while(beforeLength) {
result += (double)(values[--beforeLength] - '0') * multiplier;
multiplier *= 10.;
}
multiplier = 10.;
}
else {
if(!beforeDot)
{
result += double(ch - '0') / multiplier;
multiplier *= 10.;
} else {
values[beforeLength++] = ch;
}
seen = true;
}
}
if(beforeDot) {
multiplier = 1;
while(beforeLength) {
result += (double)(values[--beforeLength] - '0') * multiplier;
multiplier *= 10.;
}
}
if(sign) result *= -1.;
return result;
}