当前位置: 代码迷 >> 综合 >> 413:Calling Extraterrestrial Intelligence Again(翻译 )
  详细解决方案

413:Calling Extraterrestrial Intelligence Again(翻译 )

热度:84   发布时间:2023-12-05 15:37:48.0

来源:http://noi.openjudge.cn/ch0207/413/

Calling Extraterrestrial Intelligence Again

总时间限制: 

1000ms

内存限制: 

65536kB

描述

A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November 16, 1974. The message consisted of 1679 bits and was meant to be translated to a rectangular picture with 23 x 73 pixels. Since both 23 and 73 are prime numbers, 23 x 73 is the unique possible size of the translated rectangular picture each edge of which is longer than 1 pixel. Of course, there was no guarantee that the receivers would try to translate the message to a rectangular picture. Even if they would, they might put the pixels into the rectangle incorrectly. The senders of the Arecibo message were optimistic.

We are planning a similar project. Your task in the project is to find the most suitable width and height of the translated rectangular picture. The term "most suitable" is defined as follows. An integer m greater than 4 is given. A positive fraction a/b less than or equal to 1 is also given. The area of the picture should not be greater than m. Both of the width and the height of the translated picture should be prime numbers. The ratio of the width to the height should not be less than a/b nor greater than 1. You should maximize the area of the picture under these constraints.

In other words, you will receive an integer m and a fraction a/b. It holds that m > 4 and 0 < a/b <= 1. You should find the pair of prime numbers p, q such that pq <= m and a/b <= p/q <= 1, and furthermore, the product pq takes the maximum value among such pairs of two prime numbers. You should report p and q as the "most suitable" width and height of the translated picture.

输入

The input is a sequence of at most 2000 triplets of positive integers, delimited by a space character in between. Each line contains a single triplet. The sequence is followed by a triplet of zeros, 0 0 0, which indicates the end of the input and should not be treated as data to be processed.

The integers of each input triplet are the integer m, the numerator a, and the denominator b described above, in this order. You may assume 4 < m <= 100000 and 1 <= a <= b <= 1000.

输出

The output is a sequence of pairs of positive integers. The i-th output pair corresponds to the i-th input triplet. The integers of each output pair are the width p and the height q described above, in this order.

Each output line contains a single pair. A space character is put between the integers as a delimiter. No other characters should appear in the output.

样例输入

5 1 2
99999 999 999
1680 5 16
1970 1 1
2002 4 11
0 0 0

样例输出

2 2
313 313
23 73
43 43
37 53

翻译:


?1974年11月16日星期六下午,通过波多黎各的阿雷西博射电望远镜向外星智能发出了人类的信息。该消息由 1679 位组成,旨在转换为具有 23 x 73 像素的矩形图片。由于 23 和 73 都是质数,因此 23 x 73 是平移矩形图片的唯一可能大小,其每个边缘的长度都超过 1 个像素。当然,不能保证接收者会尝试将消息转换为矩形图片。即使他们这样做,他们也可能会错误地将像素放入矩形中。阿雷西博信息的发送者是乐观的。?

?我们正在计划一个类似的项目。您在项目中的任务是找到翻译后的矩形图片的最合适的宽度和高度。"最合适"一词的定义如下。给出大于 4 的整数 m。还给出了小于或等于 1 的正分数 a/b。图片的面积不应大于 m。翻译图片的宽度和高度都应该是素数。宽度与高度的比率不应小于 a/b,也不应大于 1。在这些约束下,应最大化图片的面积。?

?换句话说,您将收到一个整数 m 和一个小数 a/b。它认为 m > 4 和 0 < a/b < = 1。您应该找到一对质数 p, q,使得 pq <= m 和 a/b <= p/q <= 1,此外,乘积 pq 在两个素数对中取最大值。您应该将 p 和 q 报告为翻译图片的"最合适"宽度和高度。?

输入

?输入是最多包含 2000 个正整数三元组的序列,由中间的空格字符分隔。每行包含一个三元组。该序列后跟一个零三元组 0 0 0,表示输入的结束,不应被视为要处理的数据。?

?每个输入三元组的整数是上述整数 m、分子 a 和分母 b,按此顺序排列。您可以假设 4 < m < = 100000,1 < = a < = b < = 1000。?

输出

?输出是一对正整数序列。第 i 个输出对对应于第 i 个输入三元组。每个输出对的整数是上述宽度 p 和高度 q,按此顺序排列。?

?每条输出线包含一对。空格字符作为分隔符放在整数之间。输出中不应显示任何其他字符。?

  相关解决方案