HDU 5327(2015多校4)-Olympiad(水题)

来源:互联网 发布:乐清知临公立宿舍学校 编辑:程序博客网 时间:2024/06/05 00:21

题目地址:HDU 5327
题意:beautiful numbers的定义:就是一个数的每一位不能有相同的数字,现在给你一个区间,让你求这区间内有多少个这样的漂亮数。

#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#pragma comment(linker, "/STACK:102400000,102400000")using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const double pi= acos(-1.0);const double esp=1e-8;const int maxn=1e5+10;int f[maxn];int a[10];int check(int x){    memset(a,0,sizeof(a));    for(;x;x/=10){        if(a[x%10])            return 0;        else            a[x%10]=1;    }    return 1;}int main(){    memset(f,0,sizeof(f));    for(int i=1;i<=maxn;i++)        f[i]=f[i-1]+check(i);    int T,n,m;    scanf("%d",&T);    while(T--){        scanf("%d %d",&n,&m);        printf("%d\n",f[m]-f[n-1]);    }    return 0;}
1 0
原创粉丝点击