1005 Wei cat series story-Basketball dream
Time Limit: 0.1 seconds memory limit: 32768 K
Wei is very infatuated with basketball games and is a loyal NBA fan. He often fantasies that his fat body can also fly to dunk. In addition, he also has a special liking for his work as a basketball coach, especially for the tactics of the game. He also has a lot of research on shooting selection. The following is a question Wei has studied:
For a total of 48 minutes in an NBA basketball game, if we already know the current score A: B, A represents our score, B Represents the score of the other party, and now there is still t seconds left in the game. We simply think that the time for both sides to attack each attack is fixed to 15 seconds (less than 15 seconds, the attack does not score), and it is an alternate attack, that is, we attack once, and then the other side attack, in turn.
There are three attack methods: (the hit rate is not considered here)
1. Create a foul (assuming both of them have one penalty) and get one point;
2. 2 points for middle distance shooting;
3. Three-Point ball: 3 points.
In order to simplify the problem, we assume that in the opponent's round, because we have a good defensive performance, we only get one point for the opponent, which is fixed. That is, the opponent's attack round gets one point for each round. Now the game is in its last corner. The first round is our attack, now, Wei wants to know how many different options the coach has for us to win the game (probably not considering the hit rate ).
Input
The input contains multiple groups of data (up to 250 groups );
Each group of data contains three integers A, B, and T. A and B indicate the current score (0 <= A, B <= 200 ), t indicates the remaining time (unit: seconds 0 <= T <= 600 ).
Output
Please output the number of feasible solutions. Each group of data output occupies one row.
Sample Input
88 90 50
Sample output
6
Hint:
Example:
The current score is 88: 90. If there are 50 seconds left, the other party has a chance to attack at most (the last 5 seconds failed to attack). We have two times and the other party's final score will be 91, we can win at least 4 points in two rounds, so there are 6 solutions:
Second goal
1 3
2 2
2 3
3 1
3 2
3 3
This is a DP question. I started to think about it in a simple way. Later I found that I had to arrange the combination. Obviously, the algorithm went wrong.
The wool brother said that the primary function of arrangement and combination can be used, but I won't use this function. DP can also be used, so I wrote the DP code.
Here DP [I] [J] indicates the number of types whose I field score is J.
For detailed analysis, see the code comment:
// DP # include <cstdio> # include <cstring> int A, B, T; int Ta, TB, round, DP [30] [100]; double ans; void Init () {memset (DP, 0, sizeof (DP )); DP [1] [1] = DP [1] [2] = DP [1] [3] = 1; // This Initialization is very simple for (INT I = 2; I <= 20; ++ I) for (Int J = 1; j <= 60; ++ J) {// For each game, the score may be 1, 2, or 3, J is the score obtained before the I-th game, if (j> 1) DP [I] [J] + = DP [I-1] [J-1]; // if you get a point in this game, then its previous state is the status of the J-1 point in the previous game, then there are DP [I-1] [J-1] There are how many, so what kind of IF (j> 2) DP [I] [J] + = DP [I-1] [J-2] should be included in DP [I] [J]; // similar to the previous one, that is, if the score is 2 points, then the previous State is the State of the J-2 score of the previous one, the numbers are also included in DP [I] [J] If (j> 3) DP [I] [J] + = DP [I-1] [J-3]; // same as above} int main () {Init (); While (scanf ("% d", & A, & B, & T) = 3) {round = T/15; TA = (round + 1)/2; TB = round-ta; If (round = 0) {// This status cannot forget if (A> B) printf ("1 \ n"); else printf ("0 \ n"); continue ;} B + = Tb; int TMP = B-A + 1; if (TMP <0) TMP = 0; // you must consider this situation. If B is far smaller than, is a negative number. If this step is not completed, long ans = 0; For (INT I = TMP; I <= 60; I ++) ans + = DP [Ta] [I]; // This is the sum of the States in which the score meets the requirements after the TA match, that is,> = TMP score printf ("% i64d \ n", ANS );}}