I - Olympiad

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)[a,b] (a≤b). Please be fast to get the gold medal!

InputThe first line of the input is a single integer T (T≤1000)T (T≤1000), indicating the number of testcases.

For each test case, there are two numbers aa and bb, as described in the statement. It is guaranteed that 1≤a≤b≤1000001≤a≤b≤100000. 
OutputFor each testcase, print one line indicating the answer. 
Sample Input

2
1 10
1 1000

Sample Output

10
738打表大法好呀

 1 #include <iostream>
 2 using namespace std;
 3 #include<string.h>
 4 #include<set>
 5 #include<stdio.h>
 6 #include<math.h>
 7 #include<queue>
 8 #include<map>
 9 #include<algorithm>
10 #include<cstdio>
11 #include<cmath>
12 #include<cstring>
13 #include <cstdio>
14 #include <cstdlib>
15 #include<cstring>
16 int a[1000010],b[15];
17 int guanyinzuolian(int n)
18 {
19     memset(b,0,sizeof(b));
20     while(n!=0)
21     {
22         if(b[n%10])
23             return 0;
24         b[n%10]++;
25         n/=10;
26     }
27     return 1;
28 }
29 void lubenwei()
30 {
31     int sum=0;
32     for(int i=1;i<=100000;i++)
33         a[i]=a[i-1]+guanyinzuolian(i);
34 }
35 int main()
36 {
37     memset(a,0,sizeof(a));
38     lubenwei();
39     int t;
40     cin>>t;
41     while(t--)
42     {
43         int n,m;
44         cin>>n>>m;
45         cout<<a[m]-a[n-1]<<endl;
46     }
47 }

时间: 2024-07-31 14:33:12

I - Olympiad的相关文章

1999 Central European Olympiad in Informatics - Sightseeing Trip

算法提示 最小环问题 题目大意 在一张带权无向图上,找出至少含 3 个点且权值和最小的环,并按环上的循序输出环上的点.存在重边,无自环. 做法分析 参考最小环问题,在更新 dist[i][j] 时,记录更新其的点 k,便于回溯路径. 参考代码 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <queue> 5 #include <algorithm> 6

Olympiad

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

E - Team Olympiad

Description The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each c

hdu 5327 Olympiad

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5327 Olympiad 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 digita

codeforces B - Preparing Olympiad(dfs或者状态压缩枚举)

B. Preparing Olympiad You have n problems. You have estimated the difficulty of the i-th one as integer ci. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at le

DFS Codeforces Round #306 (Div. 2) B. Preparing Olympiad

题目传送门 1 /* 2 DFS: 排序后一个一个出发往后找,找到>r为止,比赛写了return : 3 */ 4 #include <cstdio> 5 #include <iostream> 6 #include <cstring> 7 #include <cmath> 8 #include <algorithm> 9 #include <vector> 10 #include <map> 11 #include

Codeforces Team Olympiad(暴力)

***********************************************声明****************************************************** 原创作品,出自 "晓风残月xj" 博客,欢迎转载,转载时请务必注明出处(http://blog.csdn.net/xiaofengcanyuexj). 由于各种原因,可能存在诸多不足,欢迎斧正! *******************************************

HDU 5327 Olympiad (多校)

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 yea

Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises) D

Country of Metropolia is holding Olympiad of Metrpolises soon. It mean that all jury members of the olympiad should meet together in Metropolis (the capital of the country) for the problem preparation process. There are n + 1 cities consecutively num