• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Warm up 13 [D] Different Digits

 

Different Digits
Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB
Total submit users: 45, Accepted users: 45

Problem 12751 : No special judgement

 

Problem description
The inhabitants of Nlogonia are very superstitious. One of their beliefs is that street house numbers that have a repeated digit bring bad luck for the residents. Therefore, they would never live in a house which has a street number like 838 or 1004.
The Queen of Nlogonia ordered a new seaside avenue to be built, and wants to assign to the new houses only numbers without repeated digits, to avoid discomfort among her subjects. You have been appointed by Her Majesty to write a program that, given two integers N and M, determines the maximum number of houses that can be assigned street numbers between N and M, inclusive, that do not have repeated digits.


Input
Each test case is described using one line. The line contains two integers N and M, as described above (1 ≤ N ≤ M ≤ 5000).


Output
For each test case output a line with an integer representing the number of street house numbers between N and M, inclusive, with no repeated digits.


Sample Input
87 104
989 1022
22 25
1234 1234
Sample Output
14
0
3
1
Problem Source
Latin American 2012
 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include <map>
 3 #include <queue>
 4 #include <vector>
 5 #include <string>
 6 #include <cmath>
 7 #include <cstdio>
 8 #include <cstring>
 9 #include <iostream>
10 #include <algorithm>
11 using namespace std;
12 #define maxn 1000005
13 #define mod 1000000007
14 #define ll long long
15 #define INF 0x7fffffff
16 #define FF(i,n)for(int i=0;i<n;i++)
17 int n, m;
18 int fun(int x){
19     int a[5];
20     int i = 0;
21     while (x){
22         a[i++] = x % 10;
23         x /= 10;
24     }
25     for (int j = 0; j < i;j++)
26     for (int k = j+1; k < i;k++)
27     if (a[k] == a[j])return 0;
28     return 1;
29 }
30 int main(){
31     int cas = 1;
32     int t;
33     /*scanf("%d", &t);
34     while (t--){
35         
36     }*/
37     while (~scanf("%d%d", &n,&m)){
38         t = 0;
39         for (int i = n; i <= m; i++){
40             if (fun(i))t++;
41         }
42         printf("%d\n", t);
43     }
44     return 0;
45 }
View Code

 

posted @ 2013-10-26 18:01  HaibaraAi  阅读(142)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3