0
点赞
收藏
分享

微信扫一扫

HDU 5327 Olympiad(水题)


Olympiad


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



Problem Description


[a,b] (a≤b). Please be fast to get the gold medal!


 



Input


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



点击打开链接



#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

using namespace std;
int v[11];
int h;
int p[100010];

void init()
{
    for(int i=1;i<=100000;i++)
    {
        int flag = 0;
        int t = i;
        memset(v,0,sizeof(v));
        while(t)
        {
            int k = t%10;
            t = t / 10;
            if(v[k] == 1)
            {
                flag = 1;
                break;
            }
            v[k]++;
        }
        if(flag == 0)
        {
            p[h++] = i;
        }

    }
}

int main()
{
    init();
    h = 0;
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int a,b;;
        int sum1 = 0,sum2 = 0;
        scanf("%d%d",&a,&b);
        for(int i=0;;i++)
        {
            if(p[i]<a)
            {
                sum1++;
            }
            if(p[i]<=b)
            {
                sum2++;
            }
            else if(p[i]>b)
            {
                break;
            }
        }
        printf("%d\n",sum2-sum1);
    }
    return 0;
}



举报

相关推荐

0 条评论