HUST 1600 Lucky Numbers
2016-03-07 08:28
316 查看
暴力打表。
#include<cstdio> #include<cstring> #include<cmath> #include<string> #include<algorithm> using namespace std; long long a[10000]; long long L, R; int tot; void dfs(long long num, int len) { if (len > 16) return; if (num>=1&&num<=1000000000000000&&num % 48 == 0) a[tot++] = num; dfs(num * 10 + 4, len + 1); dfs(num * 10 + 8, len + 1); } void init() { tot = 0; dfs(4, 1); dfs(8, 1); } int main() { init(); while (~scanf("%lld%lld", &L, &R)) { long long ans = 0; for (int i = 0; i < tot; i++) if (a[i] >= L&&a[i] <= R) ans++; printf("%lld\n", ans); } return 0; }
相关文章推荐
- Red Hat Linux DNS服务器搭建
- POJ 3991 Seinfeld
- 桶排序
- 上周热点回顾(2.29-3.6)
- HUST 1606 Naive
- C#语言基础— 输入与输出
- POJ 3458 Colour Sequence
- Eclipse jar打包详解
- Eclipse工程依赖
- leetcode随笔V
- 引用类型作为属性返回需谨慎
- 集成禅道和svn
- Systemd 对垒 Docker
- Systemd 对垒 Docker
- chattr 与 lsattr 命令详解
- HUST 1599 Multiple
- UESTC - 1252 24点游戏 (DFS)好题
- HDU 3903 Trigonometric Function
- 四:java中传统线程同步与通信
- svn中的Trunk,branches,tags深度理解