题意: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. ZOJ3229 Shoot the Bullet(有源汇的上下界最大流)

    #pragma warning(disable:4996) #include <iostream> #include <cstring> #include <string ...

  2. Sold out

    When will the writer see the play? 'The play may begin at any moment,'I said. 'It may have begun alr ...

  3. VBA高效删除不连续多行

    最近在搞VBA,在感叹Excel功能强大的同时,对于新接触的一门编程语言也很烦恼.很多基础的语法都要靠网上搜索.现总结一些学习到的心得. VBA高效删除不连续多行 在一个拥有几万条数据的Excel中, ...

  4. 怎么修改mysql密码

    1.用root 进入mysql后mysql>set password =password('你的密码');mysql>flush privileges; 2.使用GRANT语句 mysql ...

  5. iOS 开发--转场动画

    "用过格瓦拉电影,或者其他app可能都知道,一种点击按钮用放大效果实现转场的动画现在很流行,效果大致如下:" 本文主讲SWIFT版,OC版在后面会留下Demo下载 在iOS中,在同 ...

  6. MyBatis学习总结_04_解决字段名与实体类属性名不相同的冲突

    一.准备演示需要使用的表和数据 CREATE TABLE orders( order_id INT PRIMARY KEY AUTO_INCREMENT, order_no VARCHAR(20), ...

  7. linux查看内存

    cat /proc/meminfo 查看内存,查看最为准确. cat /proc/cpuinfo  察看CPU情况. dmesg | less   这样也可以看到,不过带太多的其他信息了. top也可 ...

  8. CentOS下的账户管理

    在Linux中,每个文件都分3类权限:账户本身的权限,账户所在群组的权限和其它权限.账户和群组是多对多的关系,即一个账户可以属于多个群组,一个群组可以包含多个账户.但是,对于每一个已登录的账户,只能存 ...

  9. SSIS ->> Control Flow And Data Flow

    In the Control Flow, the task is the smallest unit of work, and a task requires completion (success, ...

  10. 解决 emulator-5554 disconnected !Cancelling错误

    http://www.xuebuyuan.com/351215.html 使用Android模拟器经常遇到连不上.连一次掉一次等诸多问题(转载+原创) 解决办法一: 在此种情形下,重启ADB即可: 1 ...