HDU 3008 DP

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.