21675_FareySequenceAgain

2022-5-16 18:20| 发布者: Hocassian| 查看: 20| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505749573800-Problem List-采集的数据-后羿采集器.html

Pro.ID

21675

Title

Farey Sequence Again

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21675

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    The Farey sequence Fn for any positive integer n is the set of irreducible rational numbers a/b with 0 < a < bn and (a, b) = 1 arranged in increasing order. Here (a, b) mean the greatest common divisor of a and b. For example:

             F2 = {1/2}

             F3 = {1/3, 1/2, 2/3}

    Given two positive integers N and K, with K less than N, you need to find out the K-th smallest element of the Farey sequence FN.

    输入

    The first line of input is the number of test case T, 1 ≤ T ≤ 1000. Then each test case contains two positive integers N and K.  1 ≤ K < N ≤ 109.

    输出

    Description

    The Farey sequence Fn for any positive integer n is the set of irreducible rational numbers a/b with 0 < a < bn and (a, b) = 1 arranged in increasing order. Here (a, b) mean the greatest common divisor of a and b. For example:

             F2 = {1/2}

             F3 = {1/3, 1/2, 2/3}

    Given two positive integers N and K, with K less than N, you need to find out the K-th smallest element of the Farey sequence FN.

    Input

    The first line of input is the number of test case T, 1 ≤ T ≤ 1000. Then each test case contains two positive integers N and K.  1 ≤ K < N ≤ 109.

    Output

    For each test case output the K-th smallest element of the Farey sequence FN in a single line.

    Sample Input

    3
    2 1
    100 68
    101 69

    Sample Output

    1/2
    2/83
    1/42

    Source

    样例输入

    3
    2 1
    100 68
    101 69

    样例输出

    1/2
    2/83
    1/42

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部