Olympiad

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 631    Accepted Submission(s): 436

Problem Description
You
are one of the competitors of the Olympiad in numbers. The problem of
this year relates to beatiful numbers. One integer is called beautiful
if and only if all of its digitals are different (i.e. 12345 is
beautiful, 11 is not beautiful and 100 is not beautiful). Every time you
are asked to count how many beautiful numbers there are in the interval
[a,b] (a≤b). Please be fast to get the gold medal!
 
Input
The first line of the input is a single integer T (T≤1000), indicating the number of testcases.

For each test case, there are two numbers a and b, as described in the statement. It is guaranteed that 1≤a≤b≤100000.

 
Output
For each testcase, print one line indicating the answer.
 
Sample Input
2
1 10
1 1000
 
Sample Output
10
738
 
Author
XJZX
 
Source
 
Recommend
wange2014   |   We have carefully selected several similar problems for you:  5352 5351 5350 5349 5348
 
开始想用字符串做,推出每一个数之前的美丽数的总和,再将a,b的总和数相减就是它们之间的美丽数之和了。但是做了半天还是没做出来,太麻烦。题解的做法是预处理,把每一个数是不是美丽数都判一遍,判的过程中用一个数组f记录这之前的美丽数之和,最后也是两个相减,也就是f[b]-f[a-1].
 #include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 123456
#define M 12 int a,b;
int ha[M],f[N];
int judge(int x)
{
int n;
memset(ha,,sizeof(ha));
while(x)
{
n=x%;
if(ha[n])return ;
else ha[n]=;
x=x/;
}
return ;
} int main()
{
f[]=;
for(int i=;i<;i++)
{
f[i]=f[i-];
if( judge(i) )
f[i]++;
}
int t;cin>>t;
while(t--)
{
scanf("%d%d",&a,&b);
cout<<f[b]-f[a-]<<endl;
}
return ;
}

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 - 5327 Olympiad(一维前缀和)

    Olympiad Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem ...

  3. HDU 5327 Olympiad (水题)

    题意:beautiful数字定义为该数字中的十进制形式每一位都不同,给一个区间[L,R],求该区间中有多少个beautiful数字. 思路:数字不大,直接暴力预处理,再统计区间[1,i]有多少个,用c ...

  4. hdu 5288||2015多校联合第一场1001题

    pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...

  5. HDU 6140 17多校8 Hybrid Crystals(思维题)

    题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or sim ...

  6. HDU 5792---2016暑假多校联合---World is Exploding

    2016暑假多校联合---World is Exploding Problem Description Given a sequence A with length n,count how many ...

  7. HDU 6143 17多校8 Killer Names(组合数学)

    题目传送:Killer Names Problem Description > Galen Marek, codenamed Starkiller, was a male Human appre ...

  8. HDU 6045 17多校2 Is Derek lying?

    题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=6045 Time Limit: 3000/1000 MS (Java/Others)    Memory ...

  9. Time Zone 【模拟时区转换】(HDU暑假2018多校第一场)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6308 Time Zone Time Limit: 2000/1000 MS (Java/Others)  ...

随机推荐

  1. yum安装的java配置

    vim /etc/profile JAVA_HOME=/usr/lib/jvm/javaJRE_HOME=$JAVA_HOME/jreCLASS_PATH=.:$JAVA_HOME/lib/dt.ja ...

  2. hdu3594 Cactus

    仙人掌入门简单题. 先看一篇文档. #include <iostream> #include <cstring> #include <cstdio> using n ...

  3. Codeforces Round #307 (Div. 2)

    A. GukiZ and Contest time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  4. Codeforces Round #416 (Div. 2) 本来以为这个时间是晚上的,下午就没做

    A. Vladik and Courtesy time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  5. NYOJ-258/POJ-2559/HDU-1506 Largest Rectangle in a Histogram,最大长方形,dp或者单调队列!

                                         Largest Rectangle in a Histogram 这么经典的题硬是等今天碰到了原题现场懵逼两小时才会去补题.. ...

  6. [Kubernetes]Pod字段自动填充

    PodPreset(Pod预设置)在Kubernetes v1.11以后出现,开发人员只需要提交一个基本的Pod YAML,Kubernetes就可以自动给对应的Pod对象加上运维人员设定好的其他必要 ...

  7. iOS第三方-百度地图地图SDK(一)

    前言 最近项目忙完了准备把百度地图的方法都熟悉一遍,基于百度地图2.10.0,写demo的同时也写下博客来记录下 模拟器设置 我直接就复制我以前写过的一篇的图了,懒得截图... 获取百度地图KEY 让 ...

  8. CocoaAsyncSocket一个第三方Socket库

    github地址:https://github.com/robbiehanson/CocoaAsyncSocket github上的不完整,cocochina也有demohttp://code4app ...

  9. Python之回调函数

    在计算机程序设计中,回调函数,或简称回调(Callback),是指通过函数参数传递到其它代码的,某一块可执行代码的引用.这一设计允许了底层代码调用在高层定义的子程序. 有两种类型的回调函数:即bloc ...

  10. 【Luogu】P1868饥饿的奶牛(DP)

    题目链接 话说我存一些只需要按照一个关键字排序的双元素结构体的时候老是喜欢使用链式前向星…… DP.f[i]表示前i个位置奶牛最多能吃到的草.转移方程如下: f[i]=f[i-]; f[i]=max( ...