Sevens, Twos and Zeros
Time limit1sMemory limit128 MB
Find the smallest multiple of n that is at least n, uses only digits 7, 2, 0, and has at most 20 digits, or report NAV.
- Level
Hard8 of 10
- Topics
- BFS, Dynamic programming, Math, Brute force
- Solved
- No attempts yet
Problem
Given a natural number , write a program that outputs the smallest number satisfying all of the following conditions.
- ;
- written in decimal, consists only of the digits 7, 2 and 0, and does not start with 0;
- the decimal representation of has at most 20 digits;
- divided by leaves a remainder of 0.
Input
A single natural number () is given on one line.
Output
Output the number described above. If no such exists for the given , output the single word NAV.