当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1532:Mixed Numbers

题目描述
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.
输入解释
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.
输出解释
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.
输入样例
8 6
   1    
 2 |  2 
4|2| 4|3
   |    
   +    
   1    
0 0
输出样例
3.10

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1532

最后修改于 2020-10-29T06:06:31+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000