Submit | All submissions | Best solutions | Back to list |
FBH15R1C - Winning at Sports |
In the game of Sports, the object is have more points than the other team after a certain amount of time has elapsed. Scores are denoted by two hyphen-separated integers. For example, scores may include 3-2, 4-1, or 10-0. The first number is how many points you've scored, and the second is the number of points scored by the opposing team. You're very good at Sports, and consequently you always win. However, you don't always achieve victory the same way every time.
The two most extreme kinds of victory are called stress-free and stressful. In a stress-free victory, you score the first point and from then on you always have more points than your opponent. In a stressful victory, you never have more points than your opponent until after their score is equal to their final score.
Given the final score of a game of Sports, how many ways could you arrange the order in which the points are scored such that you secure a stress-free or stressful win?
Input
Input begins with an integer T, the number of games you'll play. For each game, there is one line containing the final score of the game in the format described above.
Output
For the ith game, print a line containing "Case #i: " followed by two space-separated integers, the number of ways you can achieve a stress-free or stressful win, respectively. Since these numbers may be very large, output them modulo 1,000,000,007.
Constraints
1 ≤ T ≤ 100
Since you always win, the first number in any final score will always be larger than the second. Both scores will be non-negative integers not exceeding 2000.
Explanation of Sample
In the third test case, you can get a stress-free win by scoring points 1, 2, and 4, or points 1, 2, and 3. You can get a stressful win by scoring points 2, 4, and 5, or points 3, 4, and 5.
Sample Input
5 2-1 3-1 3-2 10-5 1000-500
Sample Output
Case #1: 1 1 Case #2: 2 1 Case #3: 2 2 Case #4: 1001 42 Case #5: 70047606 591137401
This work is licensed under a Creative Commons Attribution-NonCommercial 3.0 Unported License.
Added by: | Tjandra Satria Gunawan |
Date: | 2015-01-19 |
Time limit: | 60s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY SCM qobi |
Resource: | FBHC 15 Round 1 |
hide comments
2015-01-19 18:00:09 (Tjandra Satria Gunawan)(曾毅昆)
By the definition of stressful: "In a stressful victory, you never have more points than your opponent until after their score is equal to their final score" --- That means for case 1-0 at first (0-0) the opponent already has final score so it's satisfy stressful definition. |
|
2015-01-19 14:25:04 Uttam Kanodia
Can you please exlain how the answer of the case 1-0 is (1 1) and not (1 0)? |