ZVONIMIR - To nisu istine

no tags 

 

       Using a pocket calculator, enter a positive integer K and press "+". The calculator still
shows the number K. Then again enter the number K. After pressing the "+" key for the
second time, the result is: K + K. The game goal is to obtain a number, consisting of
equal digits only, by repeating this operation many (possibly 0) times. Write a
program calcgame that determines whether it is possible to reach the goal.
       If possible, what is the first number, which consists of equal digits only and is
obtained by multiple summing?

         Little Zvonimir is playing the following game. Using a pocket calculator, he enters a positive integer K and presses "+". The calculator still shows the number K. Then again he enters the number K. After pressing the "+" key for the
second time, the result is: K + K. The game goal is to obtain a number, consisting of
equal digits only, by repeating this operation many (possibly 0) times. But soon he got bored of pressing same button so many times.

        Soon, his friends Dominik and Mislav came and he presented his problem to them. They talked about his problem for a few seconds and they knew the solution. Zvonimir was so upset and he screamed: "To nisu istine", and he placed a bet that their solution is incorrect. Please solve this problem so they can confirm that Zvonimir was wrong.

Input

On the standard input, a positive integer K is given.On the standard input, a positive integer K is given. In each test case the following inequality holds 1 <= K <= 1018.

 

Output

 If reaching the goal is impossible, print "Impossible". If possible, a line of the
standard output should contain two integers separated by a space: the first is the digit itself
and the secong is the amount of digits of the obtained number.

Example

Input:
37

Output:
1 3
Explanation:
37 + 37 + 37 = 111

hide comments
[Rampage] Blue.Mary: 2012-02-04 10:14:18

Explanation is wrong. The correct one should be: 37 + 37 + 37 = 111

OK, I've found this problem here: spoj.pl/problems/KEQ. Problem moved to tutorial section.

Last edit: 2011-12-01 12:25:19

Added by:Mislav Balunović
Date:2011-11-30
Time limit:2s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Based on problem from IIT Shumen 2011