Largest lucky number
Limits: 1 sec., 256 MiB
This statement was translated automatically from Ukrainian.
It is well known that a lucky number is a positive integer whose decimal representation contains only fours and sevens. For example, 4, 7, 47, 7777, and 4744474 are lucky numbers.
You are given a lucky number \(n\). What is the largest lucky number that can be obtained by changing exactly one digit in the number \(n\)?
Input
The single line contains a single lucky number \(n\).
Output
Output the largest number that can be obtained by replacing exactly one digit in the given number.
Constraints
\(1 \le n \le 10^9\),
\(n\) is lucky.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 7 | 4 |
| Input (stdin) | Output (stdout) |
|---|---|
| 47 | 77 |
Source: The Algo Battles 2025 - Етап 4
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|