题目描述

(Gas Mileage) Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several trips by recording miles driven and gallons used for each trip. Develop a C++ program that uses a while statement to input the miles driven and gallons used for each trip. The program should calculate and display the miles per gallon obtained for each trip and print the combined miles per gallon obtained for all tankfuls up to this point.


输入格式

The input consists of n (0<n<100) lines.
Each line consists of int_A(miles), int_B(gallons).
The last line of input consists of int(-1).


输出格式

The decimal precision of output is 6.


样例数据

输入

51 5
51 50
34 5
61 89
-1

输出

MPG this trip: 10.200000
Total MPG: 10.200000
MPG this trip: 1.020000
Total MPG: 1.854545
MPG this trip: 6.800000
Total MPG: 2.266667
MPG this trip: 0.685393
Total MPG: 1.322148

备注

You can use "setprecision()" and "fixed" to set the decimal precision of output. Use float to declare data.


操作

评测记录

优秀代码

信息

时间限制: 1s
内存限制: 128MB
评测模式: Normal

题解