Swap and her fav numbers
All submissions for this problem are available.
Swapanti was born on the 9th of October, '95. Coincidentally, her best friend was also born on the same day. As a result, she has started liking 9's and 5's a lot. She tries to include it in everything she does. Her email-id has those 2 numbers. Even all the digits of her mobile number are either 9 of 5. She gets her roll number changed if the digits are anything other than 9 and 5. Clearly, she is obsessed with 9's and 5's. Given any number N, she wants to find her next smallest favourite number M greater than N. She is also a bit lazy. Help her in finding M.
First line of the input will consist of T, the number of test cases. Each of the next T lines contains a single number N.
For each test case print Swapanti's next favourite number M, in a new line.
- 1 ≤ T ≤ 1000
- 1 ≤ N ≤ 1099
Input: 4 8 58 240 69 Output: 9 59 555 95
|Time Limit:||0.5 - 1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions