日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hdu 5327 Olympiad

發(fā)布時(shí)間:2024/1/17 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hdu 5327 Olympiad 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題目連接

http://acm.hdu.edu.cn/showproblem.php?pid=5327???

Olympiad

Description

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]\ (a \le b)$. Please be fast to get the gold medal!

Input

The first line of the input is a single integer $T\ (T \leq 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 \leq a \leq b \leq 100000$.

Output

For each testcase, print one line indicating the answer.?

Sample Input

2
1 10
1 1000

Sample Output

10
738

暴力枚舉,前綴和。。

#include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cstdio> #include<vector> #include<map> using std::map; using std::min; using std::find; using std::pair; using std::vector; using std::multimap; #define pb(e) push_back(e) #define sz(c) (int)(c).size() #define mp(a, b) make_pair(a, b) #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define cls(arr, val) memset(arr, val, sizeof(arr)) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define rep(i, n) for(int i = 0; i < (int)n; i++) #define tr(c, i) for(iter(c) i = (c).begin(); i != (c).end(); ++i) const int N = 100001; const int INF = 0x3f3f3f3f; int vis[10], sum[N + 10]; void init() {int v, j;sum[0] = 0;for(int i = 1; i <= N; i++) {v = i;bool f = true;cls(vis, 0);do vis[v % 10]++; while(v /= 10);for(j = 0; j < 10; j++) {if(vis[j] > 1) { f = false; break;}}sum[i] = sum[i - 1] + f;} } int main() { #ifdef LOCALfreopen("in.txt", "r", stdin);freopen("out.txt", "w+", stdout); #endifinit();int t, x, y;scanf("%d", &t);while(t--) {scanf("%d %d", &x, &y);printf("%d\n", sum[y] - sum[x - 1]);}return 0; }

轉(zhuǎn)載于:https://www.cnblogs.com/GadyPu/p/4796277.html

總結(jié)

以上是生活随笔為你收集整理的hdu 5327 Olympiad的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。