编程介的小学生 2019-07-31 21:53 采纳率: 20.5%
浏览 169

编程用分数化减来求解,怎么用C语言来做

Problem Description
Given two non-negative rational numbers A and B(A<B), your task is to find a fraction between (A,B).
Maybe there're many fractions in this interval. In this condition, output the fraction with the smallest sum of its denominator and molecular.

Input
The first line is an integer T(<=25) indicating the case number.
The next T lines each contains two strings, namely A and B.
A rational number contains characters '0'~'9','.','[',']' only.
Digits between '[' and ']' are recurring decimal's cycle parts.(0.[6] = 0.666...,etc.)
You may assume the input are all logical, and all the strings are no more than 16.

Output
For each case, output a fraction(as the format below) with the smallest sum of its denominator and molecular.

Sample Input
4
0 0.5
0.[6] 0.[7]
11.0[8] 11.1[5]
1.[142857] 3.[142857]

Sample Output
Case 1: 1/3
Case 2: 3/4
Case 3: 78/7
Case 4: 2/1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 fluent的在模拟压强时使用希望得到一些建议
    • ¥15 STM32驱动继电器
    • ¥15 Windows server update services
    • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
    • ¥15 模糊pid与pid仿真结果几乎一样
    • ¥15 java的GUI的运用
    • ¥15 Web.config连不上数据库
    • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
    • ¥15 怎么配置广告联盟瀑布流
    • ¥15 Rstudio 保存代码闪退