【HDOJ】5179 beautiful number
DFS。
/* 5179 */
#include <iostream>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
using namespace std; #define MAXN 1500 map<int, bool> tb;
int a[MAXN], n, v;
int buf[][] = {
{,},
{,,,}, {,,,,},
{,,,}, {,,,},
{,,},
{,,}
}; void dfs(int beg, int len, int val) {
int i, k, tmp = *val;
if (len >= )
return ;
for (i=beg; i<=buf[v][]; ++i) {
k = tmp + buf[v][i];
if (!tb[k]) {
tb[k] = true;
a[n++] = k;
}
dfs(i, len+, k);
}
} void init() {
int i, j, k; n = ;
for (v=; v<; ++v)
dfs(, , );
sort(a, a+n);
} int main() {
int t, l, r;
int i, j, k;
int ans; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif init();
scanf("%d", &t);
while (t--) {
scanf("%d %d", &l, &r);
ans = ;
for (i=; i<n; ++i)
if (l<=a[i] && r>=a[i])
++ans;
printf("%d\n", ans);
} return ;
}
【HDOJ】5179 beautiful number的更多相关文章
- 【HDOJ】3948 The Number of Palindromes
后缀数组求不重复回文子串数目.注意dp数组. /* 3948 */ #include <iostream> #include <sstream> #include <st ...
- 【HDOJ】4162 Shape Number
循环串的最小表示法. /* */ #include <iostream> #include <string> #include <map> #include < ...
- 【HDOJ】1018 Big Number
数学题,还是使用log避免大数,但是不要忘记需要+1,因为0也是1位,log(100)= 2,但却是3位. #include <stdio.h> #include <math.h&g ...
- 【HDOJ】3006 The Number of set
数据量这么小,果断状态压缩+dp. /* 3006 */ #include <iostream> #include <string> #include <map> ...
- 【转】oracle数据库NUMBER数据类型
原文:http://www.jb51.net/article/37633.htm NUMBER ( precision, scale)a) precision表示数字中的有效位;如果没有指定prec ...
- 【CF245H】Queries for Number of Palindromes(回文树)
[CF245H]Queries for Number of Palindromes(回文树) 题面 洛谷 题解 回文树,很类似原来一道后缀自动机的题目 后缀自动机那道题 看到\(n\)的范围很小,但是 ...
- 【BZOJ4026】dC Loves Number Theory 分解质因数+主席树
[BZOJ4026]dC Loves Number Theory Description dC 在秒了BZOJ 上所有的数论题后,感觉萌萌哒,想出了这么一道水题,来拯救日益枯竭的水题资源. 给 ...
- 【题解】P4755 Beautiful Pair(启发式合并的思路+分治=启发式分治)
[题解]P4755 Beautiful Pair upd: 之前一个first second烦了,现在AC了 由于之前是直接抄std写的,所以没有什么心得体会,今天自己写写发现 不知道为啥\(90\) ...
- 【LeetCode】375. Guess Number Higher or Lower II 解题报告(Python)
[LeetCode]375. Guess Number Higher or Lower II 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://f ...
随机推荐
- CentOS iSCSI客户端使用配置
配置步骤: 1.查看安装是否安装iSCSI驱动 rpm -qa|grep iscsi 2.查看yum安装源 yum list |grep iscsi 3.安装iscsi驱动 yum install i ...
- Python开发【第二十三篇】:持续更新中...
Python开发[第二十三篇]:持续更新中...
- Maven Integration for Eclipse 正确地址
m2eclipse has moved from sonatype to eclipse. The correct update site is http://download.eclipse.org ...
- 关于git status
如果只在本地修改,还没有commit,那么用git status, 打印信息为: 如果我本地没有修改文件,就是:
- Unity3D GUI学习
Unity3D内置有GUI, 首先,使用GUI实现一个按钮,并且点击实现触发, void OnGUI() { //GUI.Button (new Rect (10,10,50,50), "n ...
- C#中的三种 加密解密
刚刚学会的C#的加密与解密(三种)MD5加密/RSA加密与解密/DES加密.也是刚刚申请的blog随便发布一下. (一).MD5加密 MD5 md5 = new MD5CryptoServicePro ...
- Axiom3D学习日记 5.Frame Listeners, and Input Handling
Frame Listeners In Ogre's C++, we would register a class to receive notification before and after a ...
- eclipse下:selenium+python自动化之Chrome driver
1.下载chromedriver.exe文件: 2.下载的chromedriver.exe文件放置在chrome的安装目录下XXX\Chrome\Application\ ; 3.设置path环境变量 ...
- oracle命令的缩写原型单词方便记忆总结
$ORACLE_HOME/bin下的utilities解释 Binary First Available Description adapters ...
- visualSVN server库迁移(转)
转自:http://blog.csdn.net/yuhuijun_1/article/details/9762683 首先,VisualSVN Server Manager,包含两个路径,一个是安装路 ...