For each character, add gear changes to the four base stats, clamp HP and MP to at least 1 and attack to at least 0, then print the weighted combat power.
Easy2ImplementationMathNo attempts yetTime limit1sMemory limit128 MBNexon GT recently released "Mini Fantasy War" as the sequel to the SRPG "Super Fantasy War". As in the earlier game, Mini Fantasy War has to compute a combat power for every character. The combat power is only a weighted sum of the character's stats, so the logic is simple, but it is used all over the game, so Being wants another programmer to implement the same logic and cross-check it against his own. That is how the job of computing combat power landed on you.
There are four stats: HP, MP, attack, and defense. A character starts from four base stats and can equip gear. Each piece of gear raises or lowers a stat, and the amount of the change is given in the input. The final stat is therefore the base stat plus the change from gear.
HP and MP count as 1 whenever the sum is below 1. Attack counts as 0 whenever the sum is below 0. Defense is used as it is, even when it is negative.
Write H for the final HP, M for the final MP, A for the final attack, and D for the final defense. The combat power P is
P=1⋅H+5⋅M+2⋅A+2⋅D
Given the base stats of each character and the changes from gear, write a program that computes the final combat power.
The first line holds the number of characters whose combat power must be computed, that is the number of test cases T (1≤T≤1000).
Each of the next T lines holds 8 integers. The first four are the character's base HP, MP, attack, and defense, each between 1 and 999. The last four are the changes to HP, MP, attack, and defense from gear, each between −999 and 999.
Print the final combat power of each character on its own line, in the order the characters are given.