201440: [AtCoder]ARC144 A - Digit Sum of 2x

Memory Limit:1024 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

For a positive integer $x$, let $f(x)$ be the sum of its digit. For example, $f(144) = 1+4+4 = 9$ and $f(1)=1$.

You are given a positive integer $N$. Find the following positive integers $M$ and $x$:

  • The maximum positive integer $M$ for which there exists a positive integer $x$ such that $f(x)=N$ and $f(2x)=M$.
  • The minimum positive integer $x$ such that $f(x)=N$ and $f(2x)=M$ for the $M$ above.

Constraints

  • $1\leq N\leq 10^5$

Input

Input is given from Standard Input in the following format:

$N$

Output

Print $M$ in the first line and $x$ in the second line.


Sample Input 1

3

Sample Output 1

6
3

We can prove that whenever $f(x)=3$, $f(2x) = 6$. Thus, $M=6$. The minimum positive integer $x$ such that $f(x)=3$ and $f(2x)=6$ is $x=3$. These $M$ and $x$ should be printed.


Sample Input 2

6

Sample Output 2

12
24

Sample Input 3

100

Sample Output 3

200
4444444444444444444444444

Input

题意翻译

对于任意正整数$x$,令$f(x)$为$x$的数码和。 + 例:$f(144) = 1 + 4 + 4 = 9$. 给定一个正整数$N$,求满足条件的正整数: + 使得对于特定的$x$有 $f(x) = N$ 且$ f(2x) = M$ 的正整数M的最大值$M_{max}$ + 使得$f(x) = N$ 且$ f(2x) = M_{max}$ 的$x$的最小值$x_{min}$. ### 输入格式 一个正整数 $N$ ### 输出格式 $ M_{max}\; x_{min}$

加入题单

上一题 下一题 算法标签: