Олимпиадный тренинг

Задача 39196. Integer Divisors


Задача

Темы: ЕГЭ
Let M – the sum of 4 non-trivial divisors of an integer - two minimum and two maximum (not counting the unit and the number itself). If the number does not have 4 non-trivial divisors, then the M value is considered equal to zero.
Write a program that iterates over integers greater than  20 ​​000 000, in ascending order and looks among them for those for which the value M > 0 and digits of the number M form a non-decreasing sequence. Print the first five found numbers and their corresponding values ​​M

Output format: for each of the five such found numbers in a separate line, the number itself is displayed first, then – value M (separated by one space). Lines are displayed in ascending order of found numbers.