洞察如何选择适合你的企业的小程序开源框架来实现高效开发与管理
530
2022-10-21
Codeforces 122 C. Lucky Sum(分块)
Description
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Let next(x) be the minimum lucky number which is larger than or equals x. Petya is interested what is the value of the expression next(l) + next(l + 1) + … + next(r - 1) + next(r). Help him solve this problem.
Input
The single line contains two integers l and r (1 ≤ l ≤ r ≤ 10^9) — the left and right interval limits.
Output
In the single line print the only number — the sum next(l) + next(l + 1) + … + next(r - 1) + next(r).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.
Examples input
2 7
Examples output
33
题意
我们定义 last(i) 代表大于等于 i 最小的幸运数字,求 ∑ri=llast(i)
思路
显然分块可行,于是我们只需要写一个查找某个数字之后最小的幸运数字即可。
AC 代码
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~