$题解 P2394 【yyy loves Chemistry I】$

$ P2394  yyy  loves   Chemistry  I$

This question is not feeling so difficult? This konjac still very puzzled why the score isThe popularity of + / increaseIt?
Well, ado, together happily do question it!


\ [First: \ text {enter} \]
I believe, the first time do question when the majority of people will be so input

scanf("%Lf",&a);

But so input is wrong, and why? Since \ (a \) accuracy you are not sure, but long doubleaccuracy is only \ (18-19 \) bits.
then what should we do? Do not worry, Koucha said slowly, but fortunately scanfcan be forced to improve accuracy, so we adjusted the accuracy \ (16 \) bit (because the output is only required \ (8 \) bits), like \ (: \)

scanf("%16Lf",&n);  //long double是Lf!Lf!!Lf!!!

It \ (OK \) a.


\ [Second: \ text {Output} \]
to print a simple, direct

printf("%.8Lf\n",a/23);  //输出保留8位小数

On it.


\(My \ complete \ code:\)

#include<bits/stdc++.h>
int main()
{
    long double a;
    scanf("%16Lf",&a);
    printf("%.8Lf\n",a/23);
    return 0;
}

Guess you like

Origin www.cnblogs.com/Luke-Skywalker/p/11329038.html
yyy