Update appNew update is available. Click here to update.

Nth Number

Last Updated: 10 Sep, 2020
Difficulty: Hard

PROBLEM STATEMENT

Try Problem

In a series of numbers where each number is such that the sum of its digits equals 10. Given an integer value 'N', your task is to find the N-th positive integer whose sum of digits equals to 10.

Input Format:
The first line contains an Integer 'T' which denotes the number of test cases/queries to be run. 
Then the test cases follow. 

The first line of input for each test case/query contains an integer N, the Nth number to find.
Output Format:
For each test case, print the N-th positive integer whose sum of digits equals 10.

Output for every test case will be printed in a separate line.

Note

You do not need to print anything, it has already been taken care of. Just implement the given function.
Constraints:
1 <= T <= 100
1 <= N <= 10^7    

Time Limit: 1sec

Approach 1

The brute force approach is to iterate through numbers starting from 1. For each number, we will check its digit sum. If the digit sum equals 10 we will increment the count. When the count becomes equal to N we will return the current number.

Try Problem