题意:beautiful数字定义为该数字中的十进制形式每一位都不同,给一个区间[L,R],求该区间中有多少个beautiful数字。

思路:数字不大,直接暴力预处理,再统计区间[1,i]有多少个,用cnt[R]-cnt[L-1]即可。

 #include <bits/stdc++.h>
#define INF 0x7f7f7f7f
#define pii pair<int,int>
#define LL long long
using namespace std;
const int N=;
int has[];
int cnt[N]; void init()
{
for(int i=; i<N; i++)
{
memset(has,,sizeof(has));
int big=i;
while(big)//逐个拆出来
{
has[big%]++;
big/=;
}
int j=;
for(; j<; j++)
if(has[j]>) break;
if(j==) cnt[i]=;
}
for(int i=; i<N; i++)//统计i之前有多少个beautiful
cnt[i]+=cnt[i-];
} int main()
{
//freopen("input.txt", "r", stdin);
init();
int t, a, b;
cin>>t;
while(t--)
{
scanf("%d%d",&a,&b);
printf("%d\n",cnt[b]-cnt[a-]);
}
return ;
}

AC代码

HDU 5327 Olympiad (水题)的更多相关文章

  1. hdu 5327 Olympiad

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5327 Olympiad Description You are one of the competit ...

  2. hdu 5210 delete 水题

    Delete Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5210 D ...

  3. hdu 1251 (Trie水题)

    统计难题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131070/65535 K (Java/Others)Total Submi ...

  4. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

  5. HDU 4493 Tutor 水题的收获。。

    题目: http://acm.hdu.edu.cn/showproblem.php?pid=4493 题意我都不好意思说,就是求12个数的平均数... 但是之所以发博客,显然有值得发的... 这个题最 ...

  6. hdu 4802 GPA 水题

    GPA Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4802 Des ...

  7. hdu 4493 Tutor 水题

    Tutor Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4493 D ...

  8. hdu 5495 LCS 水题

    LCS Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5495 Descr ...

  9. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

随机推荐

  1. HDU 4569 Special equations(数学推论)

    题目 //想不出来,看了解题报告 /* 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p*p)=0那么一定有f(x)%p=0,f(x)%p=0那么一定有 ...

  2. POJ 3243 Clever Y (求解高次同余方程A^x=B(mod C) Baby Step Giant Step算法)

    不理解Baby Step Giant Step算法,请戳: http://www.cnblogs.com/chenxiwenruo/p/3554885.html #include <iostre ...

  3. PHP命名空间(Namespace)

    http://www.jb51.net/article/36389.htm 字符串形式的动态调用方式 //魔法常量__NAMESPACE__的值是当前空间名称 //可以组合成字符串并调用 $comme ...

  4. iOS第三方支付-支付宝支付

    处理手机中有无支付宝的情况支付宝调用接口: - (void)payOrder:(NSString *)orderStr      fromScheme:(NSString *)schemeStr    ...

  5. Useful for Android the development engineer from Github

    Original:http://sysmagazine.com/posts/216591/ Many plowing on open space Github, I found assemblage ...

  6. AngularJS学习笔记1——什么是AngularJS?

    Angular JS是一个由Google维护的开源的Javascript框架,主要作者为: Misko Hevery(angular JS之父, Sr. Computer Scientist at G ...

  7. 【Apache运维基础(4)】Apache的Rewrite攻略(1)

    简述 Rewirte主要的功能就是实现URL的跳转,它的正则表达式是基于Perl语言.可基于服务器级的(httpd.conf)和目录级的 (.htaccess)两种方式.如果要想用到rewrite模块 ...

  8. eclipse导入的工程前面有感叹号是什么意思

    1.尤其是从其他地方拷贝来并且直接加载的工程,刚打开往往会看到工程的图标上有个红色的感叹号,这是因为build path 出错了,里面有缺失或者无法找到的包. 2. 原因:显示红色感叹号是因为jar包 ...

  9. Java-J2SE学习笔记-查找一个String中,subString的出现次数

    1.查找一个String中,subString的出现次数 2.代码 package Test; public class TestStringContain { public static void ...

  10. Centos环境下部署游戏服务器-简介

    一.前言      在接触这个操作系统之前我一直使用的是ubuntu和mac os,这次由于游戏是测试版本,没有专业的运维人员去做这件事情,只能我这个稍微懂一点linux的人来做这件事情了.由于涉及到 ...