7463: X Number

内存限制:128 MB 时间限制:3 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

Teitoku loves many different kinds of numbers, and today Little W wants him to classify some positive integers into different categories.
There are 11categories, numbered from 0to 10. For each positive integer x, if there exists only one type of digit d(0≤d≤9)that occurs in xwith the highest frequency, then we say xshould be classified into category d, or otherwise, in case such digit doesn't exist, we say xshould be classified into category 10.
For example,
    ● 111223should be classified into category 1since digit 1occurs three times, and digits 2and 3occur less than three times respectively, and
    ● 3345544should be classified into category 4since digit 4occurs three times, and digits 3and 5occur less than three times respectively, and
    ● 112233should be classified into category 10since digits 1, 2and 3occur twice respectively.
Little W doesn't care about category 10and he just wants Teitoku to tell him the number of integers ranged from lto rthat should be classified to another category d. However, Teitoku can hardly solve this problem, so he asks you for help.

输入格式

There are several test cases.
The first line contains an integer T(1≤T≤1000), denoting the number of test cases. Then follow all the test cases.
For each test case, the only line contains three integers l, rand d(1≤l≤r≤1018,0≤d≤9), representing a problem.

输出格式

For each test case, output in one line the number of integers ranged from lto rthat should be classified to category d.

输入样例 复制

3
1 10 1
1 11 1
1 100 0

输出样例 复制

1
2
1

数据范围与提示

For the sample cases, 1 and 11 are in category 1, 100 is in category 0 and 10 is in category 10.