问题1692--【USACO】The Strange Sequence

1692: 【USACO】The Strange Sequence

时间限制: 1 Sec  内存限制: 64 MB
提交: 20  解决: 1
[提交] [状态] [讨论版] [命题人:]

题目描述

There is a sequence of positive integers a(i). For each i>1, a(i) is the least possible integer with the following two features: a(i) > a(i-1) The sum of the digits of a(i) equals the sum of the digits of 4 x a(i-1) For example, if a(1) = 4 and n = 5, the first five members of the sequence are: 4, 7, 19, 49, and 79. Given a value of a(1) and an index n, find and print the value of a(n).

输入

One line will contain two integers: a(1) ( 0 < a(1) < 20 ) and n ( 0 < n < 10000 ).

输出

One line (that ends with a newline or return/newline) with the integer a(n). Presume that a(n) will fit nicely into a signed 32 bit integer.

样例输入 复制

4 5

样例输出 复制

79

来源/分类


[提交] [状态]