Next Lucky Number
Practice
4.7 (16 votes)
Approved
Basic programming
Implementation
Medium
Open
Recursion
Two dimensional
Problem
77% Success 6054 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Lucky numbers are defined as the numbers consisting only of digits 3 and 5. So, given a number N, you have to print the least lucky number strictly greater than N.
Input:
First line of input contains number of test cases T. Each test case contains a single number N.
Output:
For each test case, print the next lucky number in a separate line.
Constraints:
1<=T<=1000
1<=N<=10100
Sample Input
4 4 48 130 98
Sample Output
5 53 333 333
Code Editor
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Submissions
Please login to view your submissions
Similar Problems
Points:30
6 votes
Tags:
AlgorithmsDynamic Programming2D dynamic programming
Points:30
1 votes
Tags:
AlgorithmsDynamic ProgrammingDynamic programmingMathMediumTwo dimensional
Points:30
58 votes
Tags:
ApprovedDynamic ProgrammingGraphsMathMediumOpenRecursionTwo dimensional
Editorial
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor