编程介的小学生 2017-08-26 16:08 采纳率: 20.5%
浏览 609
已采纳

Fractions again

Once upon a time, in a small Kingdom of Multiland the wise and good King Shuvarr the Reformer decided to repair the economy of his poor country. In order to save up some lead, which is very important to Multiland's industry he commanded to reduce usage of pencils. Because citizens of Multiland are very accurate they used very precised fractions. So the wise king limited in his decree the maximum value of denominators. Help Multilanders in this strange situation !

TASK

Your program should

read the fraction and the limit
write the fraction which is nearest to the given one and it's denominator is less or equal to the limit
if there are more solutions Your program should give the number with the lowest denominator
INPUT

In the first line of input there is C (1<=C<=100000) which is the number of the test cases. The next 2*C lines contain :

the fraction N/D (1<= N <= D <= 10^9), numerator (N) and denominator (D) are seperated by '/'
the number L (1<=L<=10^6) which is the limit of the denominator
OUTPUT

Your program has to write C lines, each of them consisting of the numerator, slash and denominator of the simplified fraction.

SAMPLE

INPUT

3
100/200
10
3/10
5
9/11
8

OUTPUT

1/2
1/3
5/6

  • 写回答

1条回答

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名