smileking 发表于 2008-6-2 18:46

这道能作出来吗?求助!

X and Y are nonnegative integers.

X < Y
if and only if
X's digit sum < Y's digit sum || ( X's digit sum == Y's digit sum && X's value < Y's value )

Given all numbers between A and B, inclusive.
Can you tell me which is the K-th minimum (0-based)?

Input


The first line of the input data will be a integer to represent the number of test cases.
For each test case there is only one line contains three integers A, B and K.
( 0 <= A <= B <= 10^9 , 0 <= K <= B-A)
There is a blank line before each test case.

Output


For each test case output the answer on a single line:
The K-th minimum.

Sample Input


3

0 10 3

50 100 20

12345 123456789 1234567

Sample Output


2
91
22150016

Hint


The order of numbers between 0 and 10, inclusive is
0,1,10,2,3,4,5,6,7,8,9

wuyufeixue 发表于 2008-6-2 19:00

怎么感觉像topcoder 的题目啊??

smileking 发表于 2008-6-2 22:01

你会做吗?我看得头都大了!也不知道从何下手!!!!!!!!

jiangzw625 发表于 2008-6-10 18:19

最笨的方法是用堆排序做。
做k次pop操作

smileking 发表于 2008-6-11 00:18

超时的啊!!!

jiangzw625 发表于 2008-6-11 20:13

////汗

////汗

[[it] 本帖最后由 jiangzw625 于 2008-6-11 20:36 编辑 [/it]]

smileking 发表于 2008-6-13 19:15

我自己解决了!

页: [1]

编程论坛