问题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.