301490: CF281B. Nearest Fraction

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Nearest Fraction

题意翻译

给你x、y、n(1~1e5),找到一个分母不大于n且与x-y最接近的分数,若有多个求分母最小的,若分母最小有多个求分子最小的

题目描述

You are given three positive integers $ x,y,n $ . Your task is to find the nearest fraction to fraction ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF281B/4ac5ad94fb5392cd96ac09e5b84eb06e8c8a0edb.png) whose denominator is no more than $ n $ . Formally, you should find such pair of integers $ a,b $ $ (1<=b<=n; 0<=a) $ that the value ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF281B/c829c21e70460346cb0c98e0e40815418eed87ca.png) is as minimal as possible. If there are multiple "nearest" fractions, choose the one with the minimum denominator. If there are multiple "nearest" fractions with the minimum denominator, choose the one with the minimum numerator.

输入输出格式

输入格式


A single line contains three integers $ x,y,n $ $ (1<=x,y,n<=10^{5}) $ .

输出格式


Print the required fraction in the format " $ a $ / $ b $ " (without quotes).

输入输出样例

输入样例 #1

3 7 6

输出样例 #1

2/5

输入样例 #2

7 2 4

输出样例 #2

7/2

Input

题意翻译

给你x、y、n(1~1e5),找到一个分母不大于n且与x-y最接近的分数,若有多个求分母最小的,若分母最小有多个求分子最小的

加入题单

上一题 下一题 算法标签: