Basic DP questions
Both the boss and the boss have 100 points of blood, and the player is the first
You can choose to apply skill attacks (N in total) or common attacks (1 in no blue, and 1 in damage) to each round. Each round, the boss will attack itself, the T-point Mana will be restored each round
Equation: DP [I] [J-A [k] + T] = max (DP [I] [J-A [k] + T], DP [I-1] [J] + B [k]);
# Include "stdio. H "# include" string. H "int INF = 0x3f3f3f; int max (int A, int B) {if (a <B) return B; else return a;} int main () {int I, n, m, t, q, J, K, ans; int DP [101] [101], a [101], B [101]; while (scanf ("% d", & N, & T, & Q )! = EOF) {If (n + T + q = 0) break; for (I = 1; I <= N; I ++) scanf ("% d", & A [I], & B [I]); A [0] = 0; B [0] = 1; M = 100/Q; If (100% Q! = 0) m ++; memset (DP,-1, sizeof (DP); ans =-1; DP [0] [100] = 0; for (I = 1; I <= m; I ++) {for (j = 0; j <= 100; j ++) if (DP [I-1] [J]! =-1) {for (k = 0; k <= N; k ++) if (a [k] <= J) {DP [I] [J-A [k] + T] = max (DP [I] [J-A [k] + T], DP [I-1] [J] + B [k]); If (DP [I] [J-A [k] + T]> = 100) {ans = I; break;} If (ANS! =-1) break;} If (ANS! =-1) break;} If (ANS =-1) printf ("My God \ n"); else printf ("% d \ n", ANS );} return 0 ;}
HDU 3008 DP