Lucky Numbers
Practice
4.6 (7 votes)
Algorithms
Dynamic programming
Introduction to dynamic programming 1
Problem
59% Success 2521 Attempts 50 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Let us call a number a lucky number if all the digits in the number are odd.
Given a number \(N\) , Alice wonders what is the nearest lucky number to \(N\).
Find a number \(X\) such that \(abs(N-X)\) is minimum and \(X\) is a lucky number.
Input Format:
First line contains an integer \(N\)
Output Format:
Print an integer \(X\) such that \(abs(N-X)\) is minimum
Incase of multiple answers, print the smallest answer
Constraints:
\(1 \leq N \leq 10^{18}\)
Submissions
Please login to view your submissions
Similar Problems
Points:50
8 votes
Tags:
Introduction to Dynamic Programming 1AlgorithmsDynamic Programming
Points:50
1 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingHardRecruit
Points:50
3 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingHardReadyRecruitTwo pointer
Editorial