Codeforces Beta Round 77 (Div. 2 Only)
B
Lucky Numbers (easy)
Codeforces
1300
原题
← AC →
翻译中…

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.

翻译中…

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.

翻译中…

One day Petya came across a positive integer $*n*$. Help him to find the least super lucky number which is not less than $*n*$.

翻译中…

Input

翻译中…

The only line contains a positive integer $*n*$ ($1 ≤ *n* ≤ 10^{9}$). This number doesn't have leading zeroes.

翻译中…

Output

翻译中…

Output the least super lucky number that is more than or equal to $*n*$.

翻译中…

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.

翻译中…

样例

Input #1
4500
Output #1
4747
InputCopy OutputCopy
Input #2
47
Output #2
47
InputCopy OutputCopy
题目信息
题号
96B
时间限制
2 s
内存限制
256 MB
标签
二分
位运算
暴力

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。