#BS0000183. Lựa chọn kích thước bức ảnh liên sao (Calling Extraterrestrial Intelligence Again)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Lựa chọn kích thước bức ảnh liên sao (Calling Extraterrestrial Intelligence Again)
Calling Extraterrestrial Intelligence Again
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A project for interstellar communication plans to represent its message as a rectangular picture. Both the width and height must be prime numbers.
You are given an integer and a positive fraction . Let be the picture width and its height, measured in pixels. A pair is valid exactly when
Find a valid pair of prime numbers that maximizes the area . The width and height may be equal. At least one valid pair is guaranteed to exist.
Input
- The only line contains integers , , and : the maximum area, the numerator, and the denominator of the minimum aspect ratio.
Output
Print two prime numbers and , separated by one space, whose product is maximum among all valid pairs.
Subtasks
- Subtask 1 (20 points): ; ; all are integers.
- Subtask 2 (30 points): ; ; all are integers.
- Subtask 3 (50 points): ; ; all are integers.
Examples
Example 1
Input
5 1 2
Output
2 2
Explanation
Since , both prime dimensions are at least . The pair has area and ratio . Any pair with one dimension at least has area at least . Therefore the answer is 2 2.
Example 2
Input
1970 1 1
Output
43 43
Explanation
Here , so forces . The largest prime with is : is within the limit, while the next prime has . The output is 43 43.
Example 3
Input
1680 5 16
Output
23 73
Explanation
Both and are prime. Their area is . The ratio condition holds because . There is no integer area between and , and cannot be a product of two primes. Hence this pair is optimal.