Banner Home Page DIY Contests Problems Ranklist Status Statistics
1034数据再次加强,如果还能水过我不管了……

浮点误差与精度控制

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 139   Accepted Submission(s) : 61

Font: Times New Roman | Verdana | Georgia

Font Size:

Problem Description

由于进制不同,10进制下的有限小数,到了二进制可能变成无限小数,而计算机保存位数有限,因此会产生误差
结合C++教材内容,初步了解double变量的使用

因为浮点误差的原因,涉及小数的程序输出,一般要求输出小数点后指定位数,以便于判断对错,对于一个double变量a,如果要求输出小数点后x位,可使用
printf( “%.xlf\n”, a );
其中.x表示输出小数点后x位,lf表示double变量输出
如 a = 1.6 输出小数点后4位
printf( “%.4lf\n”, a ); //屏幕输出 1.6000
如 a = 1.50007 输出小数点后4位
printf( “%.4lf\n”, a ); //屏幕输出 1.5001

结合以上内容,或查找double,printf相关资料,完成此题
计算a*b,输出小数点后6位

Input

Input contains multiple test cases.
For each test,input contain two real numbers a, b, your task is calculate a * b
( 0.0001 <= a, b <= 10000 )

Output

For each case, output one line contains one decimal number means the value of a * b, round to 6 decimal places.

Sample Input

1 2
1.5 2.5
0.1 0.1

Sample Output

2.000000
3.750000
0.010000

Author

916852

Statistic | Submit | Back