编程介的小学生 2019-10-01 12:16 采纳率: 20.5%
浏览 85

Mixed Numbers 数字混合的问题

Description

A mixed fraction is defined recursively as follows:

A real value is a simple mixed fraction. For simplicity, we only consider one digit positive integer numbers greater than zero (digits 1 ... 9).
If a is a real value (which is again assumed as an integer between 1 and 9), and b and c are two mixed fractions,
b

a- is a mixed fraction which is equal to a + b/c

c

Sum of a number of mixed fractions is also a mixed fraction.

One can draw a view of a mixed fraction using ASCII characters as described below:

A simple mixed fraction can be drawn using one digit character.
b

The mixed fraction a- will be drawn using a digit showing a , and a horizontal line that starts

                 c

immediately after the letter representing a (in the same row) using '-' characters. b and c are drawn recursively above and below the horizontal line respectively, such that their figures do not exceed the line from left nor right.
Sum of mixed fractions is represented by drawing the mixed fractions and inserting a '+' character between each consequence pair such that the '+' character and the first character of the next and the previous mixed fractions make a horizontal line.

We want you to write a program to calculate the value of a mixed fraction from its figure.
Input

Some 90 degree clockwise rotated figures of a number of mixed fractions are given in the input file. In the first line of each rotated mixed fraction n < 300 and m < 15000 , the length and the width of the figure, are written. In the next m lines the figure i s described ('-' is replaced with '|'). Note that each line will consists of exactly n characters so any number of spaces may be used in the shape, but anyway, the shape of the figure satisfies description explained above.
The input ends with a line containing two zeroes.
Output

For each test case write its value in a separate line. Your answer must be rounded to two digits after decimal point and the output must contain exactly two digits after the decimal point.
Sample Input

8 6
1

2 | 2
4|2| 4|3
|


  • 1
    0 0 Sample Output

3.10

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog