Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Continuous Fractions
Description A simple continuous fraction has the form: where the The previous continuous fraction could be noted as [ ⁄^{p}, with integers _{q}p > q > 0, can be represented in a unique way by a simple continuous fraction with n terms, such that ⁄^{p} = [_{q}a_{1}, a_{2}, …, a_{n}_{−1}, 1], where n and the a’s are positive natural numbers._{i}Your task is to find and print the simple continuous fraction that corresponds to a given rational number. Input Input will consist of a series of cases, each one in a line. A line describing a case contains The end of the input is indicated by a line containing Output Cases must be analyzed in the order that are read from the input. Output for each case will consist of several lines. The first line indicates the case number, starting at 1, using the format:
replacing The remaining lines must contain the continuous fraction corresponding to the rational number, - Horizontal bars are formed by sequences of dashes ‘
`-` ’. - The width of each horizontal bar is exactly equal to the width of the denominator under it.
- Blank characters should be printed using periods ‘
`.` ’. - The number on a fraction numerator must be printed center justified. That is, the number of spaces at either side must be same, if possible; in other case, one more space must be added at the right side.
Sample Input 75 34 65 60 0 0 Sample Output Case 1: 75 / 34 ..........1...... 2.+.------------- ............1.... ....4.+.--------- ..............1.. ........1.+.----- ................1 ............5.+.- ................1 Case 2: 65 / 60 ......1... 1.+.------ .........1 ....11.+.- .........1 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator