码迷,mamicode.com
首页 > 其他好文 > 详细

I - Olympiad

时间:2017-08-02 11:55:09      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:pac   sizeof   www   技术分享   called   element   ever   put   tca   

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

InputThe first line of the input is a single integer T (T1000)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 1ab1000001≤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 }
View Code

 

I - Olympiad

标签:pac   sizeof   www   技术分享   called   element   ever   put   tca   

原文地址:http://www.cnblogs.com/dulute/p/7272977.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!