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

hdoj 5327 Olmpiad

时间:2015-08-05 06:21:49      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5327

 1     #include<stdio.h>
 2     #include<cstring>
 3     const int MAXN = 100010;
 4     bool a[MAXN];
 5     int s[MAXN];
 6     int flag[10] = {0,1,2,3,4,5,6,7,8,9};
 7     void init(){
 8         int tmp;
 9         memset(a,0,sizeof(a));
10         memset(s,0,sizeof(s));
11         for( int i = 1; i <= MAXN; ++i ){
12             memset(flag,0,sizeof(flag));
13             tmp = i;
14             while(tmp != 0){
15                 if( flag[tmp % 10] == 1 ){
16                     a[i] = 1;
17                     break;
18                 }
19                 else
20                 {
21                     flag[tmp%10] = 1;
22                     tmp = tmp / 10;
23                 }
24             }
25         }
26         printf("%d",s[0]);
27         s[1] = a[1];
28         for( int i = 2; i <= MAXN; ++i){
29             s[i] = s[i-1] + a[i];
30         }
31     }
32     int main()
33     {
34         int T;
35         int a,b;
36         init();
37         scanf("%d",&T);
38         while(T--){
39             scanf("%d%d",&a,&b);
40             printf("%d\n",b - s[b] - (a-1) + s[a-1]);
41         }
42     }

 

hdoj 5327 Olmpiad

标签:

原文地址:http://www.cnblogs.com/blueprintf/p/4703557.html

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