Natatorium
InterviewTime limit2sMemory limit1024 MB
Given an area C that is the product of two distinct primes, find the two listed primes whose product is C and print them in increasing order.
- Level
Easy3 of 10
- Topics
- Hash map, Number theory
- Solved
- No attempts yet
Problem
The Arithmetics Department of Tomorrow Programming School plans to build a new pool in the basement of its building. The pool will mainly test innovative floating point arithmetic algorithms, especially how their floating properties behave in different liquids. Occasionally, staff members will also be allowed into the pool. To make the pool fit human needs, the department must choose its dimensions. The pool will be rectangular and must not be a square. Its exact surface area is fixed by the algorithms to be tested there. The company that builds the pool has offered a list of possible side lengths and guarantees that a pool with the given area can be built from lengths in the list. The department chooses which pair to use.
The list is fairly long, so the department has hired a junior programmer to find which lengths can be chosen. Before starting, the programmer made two observations. First, every available side length is a prime. Second, the surface area is a product of two distinct primes. He thinks this information may help him find suitable side lengths quickly. Solve the problem before he does.
Input
The first line contains an integer (), the area of the pool surface. The second line contains an integer (), the number of side lengths offered by the company. The third line contains distinct primes (), separated by spaces. All measurements use the same unit.
Output
Print one line with two side lengths from the offered list that can be used to build the pool, separated by a space. The first length must be smaller than the second.