zoukankan      html  css  js  c++  java
  • 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] (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
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<set>
    #include<vector>
    #include<stack>
    #include<queue>
    #include<algorithm>
    #include<cstdio>
    #include<algorithm>
    #include<functional>
    #include<sstream>
    using namespace std;
    int s[100001];
    int main()
    {
        memset(s, 0, sizeof(s));
        int flag[10];
        for (int i = 1; i <= 100000; i++)
        {
            int j = i;
            s[i] = 1;
            memset(flag, 0, sizeof(flag));
            while (j)
            {
                flag[j % 10]++;
                if (flag[j % 10] > 1)s[i] = 0;
                j /= 10;
            }
            s[i] += s[i - 1];
        }
        int l, r;
        int t;
        scanf("%d", &t);
        while (t--)
        {
            scanf("%d%d", &l, &r);
            printf("%d
    ", s[r] - s[l - 1]);
        }
        return 0;
    }
  • 相关阅读:
    堆栈信息分析
    JVM垃圾回收日志结构分析
    grep -n 显示行号
    Zabbix报告无交换内存主机 Lack of free swap space on xxxxx
    Zabbix利用msmtp+mutt发送邮件报警
    Nginx开启Gzip压缩大幅提高页面加载速度
    rsync --exclude 参数
    zabbix 监控客户端数据库 zabbix客户端
    centos 截图命令 screenshot
    centos下安装五笔输入法的教程
  • 原文地址:https://www.cnblogs.com/edych/p/7281500.html
Copyright © 2011-2022 走看看