96B.md (1154B)
1 Source: https://codeforces.com/problemset/problem/96/B 2 3 B. Lucky Numbers (easy) 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Petya loves lucky numbers. Everybody knows that positive integers are lucky if their decimal representation doesn't contain digits other than 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. 22 23 Lucky number is super lucky if it's decimal representation contains equal amount of digits 4 and 7. For example, numbers 47, 7744, 474477 are super lucky and 4, 744, 467 are not. 24 25 One day Petya came across a positive integer *n*. Help him to find the least super lucky number which is not less than *n*. 26 27 Input 28 29 The only line contains a positive integer *n* (1 ≤ *n* ≤ 109). This number doesn't have leading zeroes. 30 31 Output 32 33 Output the least super lucky number that is more than or equal to *n*. 34 35 Please, do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator. 36 37 Examples 38 39 Input 40 41 ``` 42 4500 43 ``` 44 45 Output 46 47 ``` 48 4747 49 ``` 50 51 Input 52 53 ``` 54 47 55 ``` 56 57 Output 58 59 ``` 60 47 61 ```