Olympiad
Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 347 Accepted Submission (s): 257
Problem Descriptionyou is one of the competitors of the Olympiad in numbers. The problem of the relates to beatiful numbers. One integer is called beautiful if and only if all of its digitals is different (i.e. 12345 was beautiful, and not beaut Iful and Beautiful). Every time asked to count how many beautiful numbers there is in the interval [a,b] (a≤b) . Please be fast to get the gold medal!
Inputthe first line of the input was a single integer t   ( t ≤ Span id= "mathjax-span-21" class= "mn" style= "font-family:mathjax_main; Padding-left:0.278em ">1000 ) , indicating the number of testcases.
For each test case, there is numbers a and b , as described in the statement. It's Guaranteed that 1 ≤ a ≤ b ≤ 100000 .
Outputfor each testcase and print one line indicating the answer.
Sample Input
21 101 1000
Sample Output
10738
Authorxjzx
Source2015 multi-university Training Contest 4
The subject is about determining whether a number contains duplicate numbers and the number of books that satisfy the conditions within an interval;
The time-out, each interval is counted to waste a moment, directly before each number to meet the number of conditions, the table method
#include <iostream> #include <cstdio> #include <cstring>using namespace Std;int temp[10];int ans[ 100001];int i,j,n,a,b;int fun1 (int x)//is used to determine if the number satisfies the condition { int mod; memset (temp,0,sizeof (temp)); while (x! = 0) { mod = x%; if (Temp[mod]) { return 0; } else { temp[mod]++; } x/=; } return 1;} int main () { //result hit table for (i = 1;i < 100001;i++) { if (fun1 (i)) { ans[i] = ans[i-1] + 1;< c22/>} Else { Ans[i] = ans[i-1]; } } scanf ("%d", &n); for (i = 0;i < n;i++) { scanf ("%d%d", &a,&b); printf ("%d\n", Ans[b]-ans[a] + fun1 (a));//Interval subtraction can be } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
hdu--5327 Olympiad