Problem

13 /21


Maximum product by condition

Problem

The communication channel transmits data as a sequence of positive integers. The number of numbers is not known in advance, but not less than two. The sign of the end of the data is the number 0. After the data, a control value is transmitted. It is equal to the maximum possible product of two numbers from the passed set, which is divisible by 7, but not divisible by 49. If such a product cannot be obtained, the control value is considered equal to 1.
Write an efficient program, including from memory, that will simulate the process of receiving data. The program should enter all the numbers and the control value, and print a summary report including the number of numbers received, the control value received, the calculated control value, and a match output.
Before the text of the program, briefly describe the algorithm for solving the problem, indicate the programming language used and its version.

Input
Each line of the input data contains one integer. First there are lines with basic data – positive numbers, then the number 0 (a sign of the end of the data), in the last line – control value.

Imprint
The program should output a report in the form shown below in the example.
 

 

Examples
# Input Output
1 6
7
8
9
0
64
input: 4
reference value: 64
calculated value: 63
values ​​false

The last line may contain values ​​true

depending on the result