22257_JohnnyHatesNumberTheory

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

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

Pro.ID

22257

Title

Johnny Hates Number Theory

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1200/400 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Johnny hates Number Theory! Actually, back in 2002, we came to know that Johnny couldn’t count and in 2005 we knew that Johnny couldn’t yet add. (But we did know in 2003 that Johnny was street smart enough to solve difficult graph problems!) Why Johnny decided to study Number Theory is incomprehensible to us.
    Anyhow, back to Johnny. Johnny just failed his comprehensive exam and that was all because of Euler’s Totient function (ϕ). Johnny is so angry that he decides to create his own Totient function. Here’s how he described it to his advisor:
    In number theory, the prime factors of a positive integer are the prime numbers that divide into that integer exactly, without leaving a remainder. Johnny defines function F(n), for n ≥ 2, to be the non-decreasing list of prime numbers whose product is n. For example, F(8) = <<2, 2, 2>>, F(60) = <<2, 2, 3, 5>>, and F(71) = <<71>>  (71 is a prime.) Let O(n) be the length of the list F(n) (i.e. its ordinal.) For example, O(8) = 3, O(60) = 4, and O(71) = 1. Johnny also defines function p(n) over positive integers as follows:

    The following table illustrates p(n) for the first twenty positive integers:

    Given two positive integers a and b where a ≤ b, Johnny defines his very own Totient function ϕ (a, b) as follows:

    For example, ϕ(1, 4) = −4, ϕ(16, 16) = 3, and ϕ(8, 12) = 4.
    For his dissertation, Johnny needs a program that determines the maximal ϕ within a given range [L,U]. In other words, given two positive integers L,U such that L ≤ U, the program must find the maximum ϕ(a, b) where L ≤ a ≤ b ≤ U. For example, the maximal ϕ within the range [1, 20] is 7 (which is ϕ(8, 16).)
    Write the program Johnny needs!

    输入

    Your program will be tested on one or more test cases. Each test case is specified on a single line.
    Each test case is specified using two positive integers L and U separated by one or more spaces, and satisfying the following property: 1 ≤ L ≤U <1, 000, 000
    The end of the test cases is indicated by a line made of two -1’s. That last line is is not part of the test cases.

    输出

    Description

    Johnny hates Number Theory! Actually, back in 2002, we came to know that Johnny couldn’t count and in 2005 we knew that Johnny couldn’t yet add. (But we did know in 2003 that Johnny was street smart enough to solve difficult graph problems!) Why Johnny decided to study Number Theory is incomprehensible to us.
    Anyhow, back to Johnny. Johnny just failed his comprehensive exam and that was all because of Euler’s Totient function (ϕ). Johnny is so angry that he decides to create his own Totient function. Here’s how he described it to his advisor:
    In number theory, the prime factors of a positive integer are the prime numbers that divide into that integer exactly, without leaving a remainder. Johnny defines function F(n), for n ≥ 2, to be the non-decreasing list of prime numbers whose product is n. For example, F(8) = <<2, 2, 2>>, F(60) = <<2, 2, 3, 5>>, and F(71) = <<71>>  (71 is a prime.) Let O(n) be the length of the list F(n) (i.e. its ordinal.) For example, O(8) = 3, O(60) = 4, and O(71) = 1. Johnny also defines function p(n) over positive integers as follows:

    The following table illustrates p(n) for the first twenty positive integers:

    Given two positive integers a and b where a ≤ b, Johnny defines his very own Totient function ϕ (a, b) as follows:

    For example, ϕ(1, 4) = −4, ϕ(16, 16) = 3, and ϕ(8, 12) = 4.
    For his dissertation, Johnny needs a program that determines the maximal ϕ within a given range [L,U]. In other words, given two positive integers L,U such that L ≤ U, the program must find the maximum ϕ(a, b) where L ≤ a ≤ b ≤ U. For example, the maximal ϕ within the range [1, 20] is 7 (which is ϕ(8, 16).)
    Write the program Johnny needs!

    Input
    Your program will be tested on one or more test cases. Each test case is specified on a single line.
    Each test case is specified using two positive integers L and U separated by one or more spaces, and satisfying the following property: 1 ≤ L ≤U <1, 000, 000
    The end of the test cases is indicated by a line made of two -1’s. That last line is is not part of the test cases.
    Output
    For each test case, output the result on a single line using the following format:
    k. result
    Where k is the test case number (starting at 1,) and result is the maximal ϕ that can be found within the range [L,U].
    Sample Input
    1 5
    1 20
    10 20
    900000 901000
    -1 -1
    Sample Output
    1. 1
    2. 7
    3. 5
    4. 2551
    Source

    样例输入

    1 5
    1 20
    10 20
    900000 901000
    -1 -1

    样例输出

    1. 1
    2. 7
    3. 5
    4. 2551

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部