Connection Status:
Competition Arena > TheLargestLuckyNumber
SRM 403 · 2008-05-29 · by Vasyl[alphacom] · Simulation
Class Name: TheLargestLuckyNumber
Return Type: int
Method Name: find
Arg Types: (int)
Problem Statement

Problem Statement

John thinks 4 and 7 are lucky digits, and all other digits are not lucky. A lucky number is a number that contains only lucky digits in decimal notation.

You are given an int n. Return the largest lucky number that is less than or equal to n.

Constraints

  • n will be between 4 and 1,000,000, inclusive.
Examples
0)
100
Returns: 77

77 is the largest lucky number that is not greater than 100.

1)
75
Returns: 74

74 is the lucky number that immediately precedes 77.

2)
5
Returns: 4

The smallest lucky number is 4.

3)
474747
Returns: 474747

n is a lucky number.

4)
1000000
Returns: 777777

Submissions are judged against all 49 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class TheLargestLuckyNumber with a public method int find(int n) · 49 test cases · 2 s / 256 MB per case

Submitting as anonymous