PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000183. Lựa chọn kích thước bức ảnh liên sao (Calling Extraterrestrial Intelligence Again)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

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 mm and a positive fraction a/ba/b. Let pp be the picture width and qq its height, measured in pixels. A pair (p,q)(p,q) is valid exactly when

pq≤m,ab≤pq≤1.pq\le m,\qquad \frac{a}{b}\le\frac{p}{q}\le1.

Find a valid pair of prime numbers (p,q)(p,q) that maximizes the area pqpq. The width and height may be equal. At least one valid pair is guaranteed to exist.

Input

  • The only line contains integers mm, aa, and bb: the maximum area, the numerator, and the denominator of the minimum aspect ratio.

Output

Print two prime numbers pp and qq, separated by one space, whose product is maximum among all valid pairs.

Subtasks

  • Subtask 1 (20 points): 5≤m≤10005\le m\le 1000; 1≤a≤b≤10001\le a\le b\le1000; all are integers.
  • Subtask 2 (30 points): 5≤m≤100005\le m\le 10000; 1≤a≤b≤10001\le a\le b\le1000; all are integers.
  • Subtask 3 (50 points): 5≤m≤1000005\le m\le 100000; 1≤a≤b≤10001\le a\le b\le1000; all are integers.

Examples

Example 1

Input

5 1 2

Output

2 2

Explanation

Since m=5m=5, both prime dimensions are at least 22. The pair (2,2)(2,2) has area 4≤54\le5 and ratio 1∈[1/2,1]1\in[1/2,1]. Any pair with one dimension at least 33 has area at least 2⋅3=6>52\cdot3=6>5. Therefore the answer is 2 2.

Example 2

Input

1970 1 1

Output

43 43

Explanation

Here a=b=1a=b=1, so 1≤p/q≤11\le p/q\le1 forces p=qp=q. The largest prime with p2≤1970p^2\le1970 is 4343: 432=184943^2=1849 is within the limit, while the next prime 4747 has 472=2209>197047^2=2209>1970. The output is 43 43.

Example 3

Input

1680 5 16

Output

23 73

Explanation

Both 2323 and 7373 are prime. Their area is 23⋅73=1679≤168023\cdot73=1679\le1680. The ratio condition holds because 23⋅16=368≥365=73⋅523\cdot16=368\ge365=73\cdot5. There is no integer area between 16791679 and 16801680, and 16801680 cannot be a product of two primes. Hence this pair is optimal.