Non Decreasing Digits
Submit
Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.
Problem
A number is said to be made up of non-decreasing digits if all the digits to the left of any digit is less than or equal to that digit.For example, the four-digit number 1234 is composed of digits that are non-decreasing. Some other four-digit numbers that are composed of non-decreasing digits are 0011, 1111, 1112, 1122, 2223. As it turns out, there are exactly 715 four-digit numbers composed of non-decreasing digits.
Notice that leading zeroes are required: 0000, 0001, 0002 are all valid four-digit numbers with non-decreasing digits.
For this problem, you will write a program that determines how many such numbers there are with a specified number of digits.
Input
The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set is a single line that contains the data set number, followed by a space, followed by a decimal integer giving the number of digits N, (1 ≤ N ≤ 64).
Output
For each data set there is one line of output. It contains the data set number followed by a single space, followed by the number of N digit values that are composed entirely of non-decreasing digits.
Resource: ACM Greater New York Regionals 2010
-- Deb
Options
exec is denied
now post-mortem time, all source codes will be revealed
Sample input:_
64
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 53
53 54
54 55
55 56
56 57
57 58
58 59
59 60
60 61
61 62
62 63
63 64
64 1
Sample output:
1 55
2 220
3 715
4 2002
5 5005
6 11440
7 24310
8 48620
9 92378
10 167960
11 293930
12 497420
13 817190
14 1307504
15 2042975
16 3124550
17 4686825
18 6906900
19 10015005
20 14307150
21 20160075
22 28048800
23 38567100
24 52451256
25 70607460
26 94143280
27 124403620
28 163011640
29 211915132
30 273438880
31 350343565
32 445891810
33 563921995
34 708930508
35 886163135
36 1101716330
37 1362649145
38 1677106640
39 2054455634
40 2505433700
41 3042312350
42 3679075400
43 4431613550
44 5317936260
45 6358402050
46 7575968400
47 8996462475
48 10648873950
49 12565671261
50 14783142660
51 17341763505
52 20286591270
53 23667689815
54 27540584512
55 31966749880
56 37014131440
57 42757703560
58 49280065120
59 56672074888
60 65033528560
61 74473879480
62 85113005120
63 97082021465
64 10
Ranking
Rank | User | Size | Time | Date | Statistics |
---|
1 | tails | 45 | 0.0019 | 2011/04/20 04:49:47 | 0B / 16B / 29B |
2 | teebee | 46 | 0.0174 | 2011/04/24 17:18:10 | 0B / 18B / 25B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | leonid | 53 | 0.0301 | 2011/04/20 11:07:44 | 0B / 31B / 18B |
2 | hallvabo | 53 | 0.0319 | 2011/04/30 05:58:03 | 0B / 31B / 21B |
3 | recursive | 62 | 0.0262 | 2011/04/20 22:54:19 | 2B / 38B / 16B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | youz | 78 | 0.0410 | 2011/04/28 18:23:09 | 0B / 30B / 39B |
2 | kaki | 78 | 0.0759 | 2011/04/29 06:24:02 | 0B / 36B / 35B |
3 | kaki | 75 | 0.0186 | 2013/03/25 06:47:33 | 0B / 31B / 40B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | kozima | 69 | 0.5132 | 2011/04/28 11:08:15 | 0B / 32B / 32B |
2 | youz | 69 | 0.0565 | 2011/04/28 18:22:31 | 0B / 32B / 32B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | youz | 63 | 1.9927 | 2011/04/28 18:22:26 | 0B / 23B / 31B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | nn | 66 | 0.0004 | 2011/04/30 00:03:01 | 0B / 32B / 34B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | *yuko* | 79 | 0.0004 | 2011/04/24 12:04:49 | 0B / 51B / 27B |
2 | *yuko* | 76 | 0.0128 | 2011/12/03 01:17:41 | 0B / 48B / 26B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | *yuko* | 218 | 0.0027 | 2011/04/24 13:41:34 | 0B / 151B / 40B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | pooq | 59 | 0.2015 | 2011/04/19 07:20:13 | 0B / 28B / 29B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | whio | 15 | 0.0626 | 2017/08/05 03:08:57 | 2B / 8B / 5B |
Rank | User | Size | Time | Date | Statistics |
---|
1 | nn | 61 | 2.3722 | 2011/04/25 22:41:07 | 0B / 34B / 24B |
Language Ranking_
Rank | Lang | User | Size | Score |
1 | gs2 | whio | 15 | 10000 |
2 | J | I., S.(pooq)(devious) | 29 | 5172 |
3 | GolfScript | nooodl | 33 | 4545 |
4 | Perl | tails | 45 | 3333 |
5 | Logo | teebee | 46 | 3260 |
6 | Ruby | leonid | 50 | 3000 |
7 | AWK | hemflit | 51 | 2941 |
8 | Python | leonid | 53 | 2830 |
9 | BASIC | *yuko* | 56 | 2678 |
10 | Maxima | pooq | 59 | 2542 |
11 | Groovy | nn | 61 | 2459 |
12 | Arc | youz | 63 | 2380 |
13 | JavaScript | nn | 66 | 2272 |
14 | Common LISP | kozima | 69 | 2173 |
15 | Scheme | kaki | 75 | 2000 |
16 | Fortran | *yuko* | 76 | 1973 |
17 | C | nn | 85 | 1764 |
18 | Pascal | *yuko* | 96 | 1562 |
19 | OCaml | m.ukai | 134 | 1119 |
20 | COBOL | *yuko* | 218 | 688 |
return to the top page