【题目链接】

点击打开链接

【算法】

数位DP

和上一题 : HDU3555很像

【代码】

#include<bits/stdc++.h>
using namespace std;
#define MAXL 10 long long n,m;
long long a[MAXL],dp[MAXL][MAXL]; template <typename T> inline void read(T &x) {
long long f = ; x = ;
char c = getchar();
for (; !isdigit(c); c = getchar()) { if (c == '-') f = -f; }
for (; isdigit(c); c = getchar()) x = (x << ) + (x << ) + c - '';
x *= f;
}
template <typename T> inline void write(T x) {
if (x < ) { putchar('-'); x = -x; }
if (x > ) write(x/);
putchar(x%+'');
}
template <typename T> inline void writeln(T x) {
write(x);
puts("");
}
inline void getdp() {
long long i,j,k;
dp[][] = ;
for (i = ; i <= MAXL; i++) {
for (j = ; j <= ; j++) {
if (j == ) continue;
for (k = ; k <= ; k++) {
if (k == ) continue;
if (j == && k == ) continue;
dp[i][j] += dp[i-][k];
}
}
}
}
inline long long calc(long long n) {
long long i,j,ans = ;
a[] = ;
while(n) {
a[++a[]] = n % ;
n /= ;
}
a[a[]+] = ;
for (i = a[]; i >= ; i--) {
for (j = ; j < a[i]; j++) {
if (j == ) continue;
if (a[i+] == && j == ) continue;
ans += dp[i][j];
}
if (a[i] == ) break;
if (a[i+] == && a[i] == ) break;
}
return ans;
} int main() { getdp();
while (true) {
read(n); read(m);
if (!n && !m) break;
writeln(calc(m+)-calc(n));
} return ; }

最新文章

  1. 数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇
  2. ACM: FZU 2112 Tickets - 欧拉回路 - 并查集
  3. PHPstudy 无法启动Apache
  4. Java final数据
  5. async4j 普通用法、整合spring用法
  6. Java 实现阶乘算法
  7. cscope 的使用
  8. WebApi2官网学习记录---Content Negotiation
  9. ESCAPE用法
  10. HDU 1032 The 3n + 1 problem
  11. php url 伪静态
  12. JAVA基础--常用类 String,StringBuffer, 基础数据类型包装类, Math类, Enum类
  13. 【转】Spring AOP 实现之CGLIB
  14. LindDotNetCore~职责链模式的应用
  15. Mysql--alter命令小特点
  16. Redis之持久化(RDB AOF)
  17. AtCoder 瞎做
  18. POJ-2533.Longest Ordered Subsequence (LIS模版题)
  19. How to extract a complete list of extension types within a directory?
  20. maven 打jar 被引用后 出现 cannot resolve symbol 错误 生成jar包形式代码文件组织格式 非springboot文件组织格式

热门文章

  1. Croc Champ 2013 - Round 2 C. Cube Problem
  2. [Bzoj5043][Lydsy1709月赛]密码破译(按位dp)
  3. Vim出现:_arguments:450: _vim_files: function definition file not found的问题解决
  4. 前端模板Nunjucks简介
  5. String、StringBuffer和StringBuilder的差别
  6. keras模型总结
  7. js中有包装类,java中也有包装类
  8. Swift的可选链,类型转换和扩展
  9. 腾讯云图片鉴黄集成到C# SQL Server 怎么在分页获取数据的同时获取到总记录数 sqlserver 操作数据表语句模板 .NET MVC后台发送post请求 百度api查询多个地址的经纬度的问题 try{}里有一个 return 语句,那么紧跟在这个 try 后的 finally {}里的 code 会 不会被执行,什么时候被执行,在 return 前还是后? js获取某个日期
  10. LeetCode232 Implement Queue using Stacks Java 题解