Problem Statement
You are going to take part in a popular online programming contest. During the contest the contestants will be split across room rooms, with exactly size contestants in each room. (Hence, there will be exactly room*size contestants.) The rooms will be numbered from 1 to room.
The contest is such that there will be no ties. After the contest, each contestant will have a distinct rank between 1 and room*size, inclusive. (The contestant with rank 1 is the winner.)
A room winner is the contestant with the best (i.e., smallest) rank in their room.
You are interested in the ranks of all room winners. Once the contest finishes, you will write down a sequence of room positive integers. For each i, the i-th element of this sequence will be the rank of the winner of room i.
You are given the
Definition
- Class:
- XYZCoder
- Method:
- countWays
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int countWays(int room, int size)
- (be sure your method is public)
Constraints
- room will be between 1 and 100, inclusive.
- size will be between 1 and 100, inclusive.
Examples
2
1
Returns: 2
There are 2 rooms, each with 1 contestant. If contestant in room 1 wins the contest, you will write down the list {1,2}. Otherwise, you will write down the list {2,1}. Note that these are considered to be two distinct sequences.
1
2
Returns: 1
There is 1 room with 2 contestants. Regardless of which of them wins, the winner of the only room will have rank 1, so you will write down the list {1}.
2
2
Returns: 4
Now we have 2 rooms, each with 2 contestants. In this case you will write down one of the following four lists: {1,2}, {2,1}, {1,3}, or {3,1}. Note the following: You will never write down the list {2,3}, because the winner of the entire contest (rank 1) has to be the winner of one of the rooms. You will never write down the list {1,4}, because the contestant with rank 4 cannot be a room winner in this setting.
4
5
Returns: 6840
100
100
Returns: 718243627
55
96
Returns: 271394236
29
85
Returns: 186283699
29
100
Returns: 884148227
92
83
Returns: 78404347
83
71
Returns: 127505228
19
46
Returns: 709848259
23
15
Returns: 154577394
49
49
Returns: 827095815
62
42
Returns: 17280594
41
54
Returns: 422877699
34
23
Returns: 598119987
4
9
Returns: 42840
79
7
Returns: 418870014
33
72
Returns: 172932139
66
97
Returns: 714389422
62
16
Returns: 866154756
94
6
Returns: 308906022
62
7
Returns: 186334570
73
70
Returns: 497002066
1
73
Returns: 1
51
26
Returns: 739203971
84
16
Returns: 434079293
74
29
Returns: 12942240
2
58
Returns: 116
64
32
Returns: 34205287
1
59
Returns: 1
92
83
Returns: 78404347
44
79
Returns: 157109850
81
99
Returns: 640894437
59
25
Returns: 711410043
10
91
Returns: 217459910
24
35
Returns: 161911161
16
9
Returns: 440660168
65
54
Returns: 481427123
77
39
Returns: 317353169
97
81
Returns: 49314584
24
33
Returns: 927344964
14
32
Returns: 278794421
25
80
Returns: 284832361
22
34
Returns: 274986521
89
90
Returns: 509687471