22690_Euclidagain

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

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

Pro.ID

22690

Title

Euclid again

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

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

    Euclid Algorithm is effective when calculating GCD (Greatest Common Divisor) of two integers. Here is an example in C:

    long gcd ( long x, long y )

    // assume that x ≥ y and x > 0
    {
      if(!y) return x; return gcd(y, x%y);

    }

    Given two integers x and y, how many times the gcd function will be called finally? The following function will solve this problem:

    long f(long x, long y)

    // assume that x ≥ y and x > 0
    {
       if(!y) return 1; else return f(y, x%y)+l;

    }

    Now let us define a new function g(k):

    g(k) = min{ x | f(x, y)=k, x y, x > 0, y 0 }

    Your task is to calculate the function g(k) efficiently.

    输入

    The first line of the input data is an integer C, the number of the test cases followed.

    The input for each test case is an integer k ( 0 < k < 81 ).

    输出

    Description

    Euclid Algorithm is effective when calculating GCD (Greatest Common Divisor) of two integers. Here is an example in C:

    long gcd ( long x, long y )

    // assume that x ≥ y and x > 0
    {
      if(!y) return x; return gcd(y, x%y);

    }

    Given two integers x and y, how many times the gcd function will be called finally? The following function will solve this problem:

    long f(long x, long y)

    // assume that x ≥ y and x > 0
    {
       if(!y) return 1; else return f(y, x%y)+l;

    }

    Now let us define a new function g(k):

    g(k) = min{ x | f(x, y)=k, x y, x > 0, y 0 }

    Your task is to calculate the function g(k) efficiently.

    Input

    The first line of the input data is an integer C, the number of the test cases followed.

    The input for each test case is an integer k ( 0 < k < 81 ).

    Output

    The output should consist of C lines, one line for each test case, only containing one integer which represents the value of g(k). No redundant spaces are needed.

    Sample Input

    1
    1

    Sample Output

    1

    Source

    样例输入

    1
    1

    样例输出

    1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部