Home > Back-end >  Pitia on the topic, code no problem, the result of the online submission always prompt operation tim
Pitia on the topic, code no problem, the result of the online submission always prompt operation tim

Time:04-22


You find out the cause of the timeout, and more,
 # include & lt; Stdio. H> 
Int main ()
{

Long int h;
Long int n;
Double s=0, x=0;
int i;
The scanf (" % d % d ", & amp; H, & amp; N);
X=h;
for(i=1; i<=n; I++)
If (I==1)
S +=x;
The else {
X *=0.5;
S +=2 * x;
}
X *=0.5;
Printf (" % 1 f %. 1 f ", s, x);
}

CodePudding user response:

Add a newline output at the end?

CodePudding user response:

Reference:
 # include & lt; Stdio. H> 
Int main ()
{

Long int h;
Long int n;
Double s=0, x=0;
int i;
The scanf (" % d % d ", & amp; H, & amp; N);
X=h;
for(i=1; i<=n; I++)
If (I==1)
S +=x;
The else {
X *=0.5;
S +=2 * x;
}
X *=0.5;
Printf (" % 1 f %. 1 f \ n ", s, x);//'\ n'

return 0;
}
  • Related