Tasks:
 
Task DescriptionDiscussion (0)
Task :: niz
An array of integers A[i] (i > 1) is defined in the following way: an element A[k] ( k > 1) is the smallest number greater than A[k-1] such that the sum of its digits is equal to the sum of the digits of the number 4* A[k-1] .

You need to write a program that calculates the N th number in this array based on the given first element A[1] .

INPUT:
In one line of standard input there are two numbers seperated with a single space: A[1] (1 <= A[1] <= 100) and N (1 <= N <= 10000).

OUTPUT:
The standard output should only contain a single integer A[N] , the Nth number of the defined sequence.


Input:
7 4

Output:
79

Explanation:
Elements of the array are as follows: 7, 19, 49, 79... and the 4th element is solution.
Submit Solution
:
:
Available Languages
Task info
Name:niz
Time:1 sec.
Memory:1 MB
#Tests:10
AddedBy: admin
Task Ratings
Difficulty:

4.2 (45 votes)
Quality:

4.7 (35 votes)
Acceptance Rate
Recent Submissions
Fastest Solutions
UserTime
troka 0 s.
osborn 0 s.
wanchope-banned 0 s.
johndoe 0 s.
oracle 0 s.
petart 0 s.
StPiere 0 s.
iloahz 0 s.
zvoc333 0 s.
Slobodn94 0 s.
Solved By