Just a HookTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 42212 Accepted Submission(s): 20314 Problem Description In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length.Now Pudge wants to do some operations on the hook. Let us number the consecutive metallic sticks of the hook from 1 to N. For each operation, Pudge can change the consecutive metallic sticks, numbered from X to Y, into cupreous sticks, silver sticks or golden sticks. The total value of the hook is calculated as the sum of values of N metallic sticks. More precisely, the value for each kind of stick is calculated as follows: For each cupreous stick, the value is 1. For each silver stick, the value is 2. For each golden stick, the value is 3. Pudge wants to know the total value of the hook after performing the operations. You may consider the original hook is made up of cupreous sticks. Input The input consists of several test cases. The first line of the input is the number of the cases. There are no more than 10 cases. Output For each case, print a number in a line representing the total value of the hook after the operations. Use the format in the example. Sample Input 1 10 2 1 5 2 5 9 3 Sample Output Case 1: The total value of the hook is 24. Source 2008 “Sunline Cup” National Invitational Contest Recommend wangye 线段树板子题,区间[x,y]内的值都变成z; |
HDU - 1698 Just a Hook(线段树区间更新 替换值)
猜你喜欢
转载自blog.csdn.net/weixin_42754600/article/details/81394154
今日推荐
周排行