Marks :10
: 0 | : 0
Alex has a book of an Infinite number of pages. Imagine practically when a book is opened $$$2$$$ pages get opened $$$1$$$ on left and $$$1$$$ on the right side except starting page which doesn't have any page to its left. In an open book left and right page numbers which open together form a spread. $$$1^{st}$$$ page doesn't have any page to its left so page number 1itself forms a spread and further all spreads have $$$2$$$-page numbers in them. The first spread contains page $$$1$$$, the second spread contains pages $$$2$$$ and $$$3$$$, the third spread contains pages $$$4$$$ and $$$5$$$ and the fourth spread contains pages $$$6$$$ and $$$7$$$ and so on.
Your task is to determine the first page number of the very first spread where the sum of digits of the page numbers is $$$S$$$. If no such spread exists, print $$$-1$$$.
Note: Page number $$$1$$$ itself forms a spread and thus is the first page for the first spread.
The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.
The first and only line of each testcase contains an integer $$$S$$$ $$$(1 \le S \le 10^5)$$$. It is guaranteed that the sum of $$$S$$$ over all the testcases does not exceed $$$10^5$$$.
For each test case, print the answer to the problem in a single line.
3194
1 4 -1
In sample test case 2,
You need to login to view your submissions.
You need to login to view all submissions.
Result : Executed
Feel something is wrong with the test cases?
Result : Accepted
Test Cases :
But to Run or Submit the Problem, you need to Log In.
Continue to Log InYour challenge has been submitted successfully.
You will get a response soon via WhatsApp or Email.
Do let us know your issue.