CF146B.Lucky Mask
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Petya loves lucky numbers very much. Everybody knows that lucky numbers are positive integers whose decimal record contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.
Petya calls a mask of a positive integer n the number that is obtained after successive writing of all lucky digits of number n from the left to the right. For example, the mask of number 72174994 is number 7744, the mask of 7 is 7, the mask of 9999047 is 47. Obviously, mask of any number is always a lucky number.
Petya has two numbers — an arbitrary integer a and a lucky number b. Help him find the minimum number c (c > a) such that the mask of number c equals b.
佩佳非常喜欢幸运数字。众所周知,幸运数字是指十进制表示中仅包含幸运数字 4 和 7 的正整数。例如,47、744、4 是幸运数字,而 5、17、467 不是。
佩佳将一个正整数 $ n $ 的**掩码(mask)**定义为:将 $ n $ 中所有幸运数字(即 4 和 7)按从左到右的顺序依次写出所得到的数。例如,72174994 的掩码是 7744,7 的掩码是 7,9999047 的掩码是 47。显然,任意数的掩码总是一个幸运数字。
佩佳有两个数——一个任意整数 $ a $ 和一个幸运数字 $ b $。请帮他找出满足以下条件的最小数 $ c : c > a $,且 $ c $ 的掩码等于 $ b $。
输入格式
The only line contains two integers a and b (1 ≤ a, b ≤ 105). It is guaranteed that number b is lucky.
仅一行,包含两个整数 a 和 b(1 ≤ a, b ≤ 105)。保证数字 b 是幸运数。
输出格式
In the only line print a single number — the number c that is sought by Petya.
在唯一的一行中输出一个整数——即 Petya 所寻找的数 c。
输入输出样例
输入#1
1 7
输出#1
7
输入#2
100 47
输出#2
147
输入解题思路,AI测评打分。不知道怎么写?