logo AlgoBeat OnlineJudge
登录 注册

#206215. [NWRRC 2014] Digits

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Little Petya likes integers. Recently he has learned about different properties of sums of number's digits. For example, if the sum of number's digits is divisible by , then the number itself is divisible by as well.

Now little Petya is interested in numbers with equal sum of digits. He asks his older brother Dima to find positive integers with equal sum of digits and minimal possible total sum. Dima has other important things to do, so he asked you to write a program that solves this problem for him.

输入格式

Input file contains a single integer .

输出格式

Output the minimal possible sum of positive integers, that all have same sum of digits.

样例

样例输入 1

2

样例输出 1

11

样例输入 2

3

样例输出 2

33

数据范围与提示

Time limit: 2 s, Memory limit: 256 MB.