404651: GYM101604 C Wet Shark and Digit Enemies
Description
Wet Shark has a function , which returns the sum of the squares of the digits of a number. For example, and .
Dry Shark is trying to fight many enemies. These enemies are strange, however, and each enemy is represented by a different positive integer, let's call it ID. Dry Shark has a function , which takes the ID of the enemy and returns the amount of power that enemy has. The body of the function is , which utilises the function that Wet Shark gave to him. Note that and
Dry Shark is given a number n. For a number n, Dry Shark knows there could potentially be any enemy whose number has n digits in it. Formally, given an integer n, the enemies could be represented as any integer from 10n - 1 to 10n - 1, inclusive. For example, if n = 2, enemies could be represented by any integer from 10 to 99 inclusive.
Dry Shark wants to know four things:
1) The ID of any of the enemies with maximum power
2) The ID of any of the enemies with minimum power
3) The power of the enemies with maximum power
4) The power of the enemies with minimum power
InputThe only line contains an integer n (1 ≤ n ≤ 2, 500, 000).
OutputOutput 4 lines, one integer on each line, representing the things Dry Shark wants to know.
The first line should state the ID of any of the enemies with maximum power.
The second line should state the ID of any of the enemies with minimum power.
The third line should state the power of the enemies with maximum power.
The fourth line should state the power of the enemies with minimum power.
If there are multiple solutions to any of Wet Shark's queries, you can output any of them.
ExamplesInput1Output
1Note
9
0
-72
Problem note: 001 is not a valid 3-digit ID because it is not in the range 102 to 103 - 1. 0 is not a valid 1-digit ID for a similar reason.
Sample Test 1: We can tabulate GetPower(n) for all 1-digit IDs:
Therefore, the minimum is -72, the maximum is 0, and values 9 and 1, respectively, produce these.