Balsa For The Three
All submissions for this problem are available.
Read problems statements in Mandarin chinese , Russian and Vietnamese as well.It's well known that our friend Balsa likes the digit $3$ very much. He's so obsessed with this digit that he spends time thinking about it even during holidays. Today, Balsa invented an interesting problem: For a positive integer $N$, find the smallest integer greater than $N$ such that its decimal representation contains the digit $3$ at least three times. You are given the integer $N$. Please solve this problem for Balsa. ### Input - The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. - The first and only line of each test case contains a single integer $N$. ### Output For each test case, print a single line containing one integer — the smallest number greater than $N$ containing the digit $3$ at least three times. ### Constraints - $1 \le T \le 40$ - $1 \le N \le 2 \cdot 10^9$ ### Example Input ``` 3 221 333 3002 ``` ### Example Output ``` 333 1333 3033 ```
|Tags||allllekssssa, bruteforce, cook-off, cook97, taran_1407|
|Time Limit:||0.5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, 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, kotlin, PERL6, TEXT, SCM chicken, CLOJ, COB, FS|
Fetching successful submissions