HBC245412SocialDistaHBCingPeach Conference题解

上官魅 算法基础篇 49 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
Sun Wukong was honored as the great saint of Qitian. He was very happy, so he held a peach meeting for the monkeys . To make it more interesting, Sun Wukong decided to throw the dice. The conference will roll the dice Q times, forming Q instructions, each in the form of ’m a b’, where m is an integer label, and a and b are monkey’s ID. The meaning of each instruction is as follows: 1. If m > 0, send m peaches to each monkey in ID interval [a, b]; 2. If m < 0, remove |m| peaches from each monkey in the ID interval [a, b] ; 3. If m = 0, calculate the sum of peaches of each monkey in the interval [a, b]; now you are invited to preside over the peach conference, can you complete the task according to the requirements of Sun Wukong?

Sun Wukong was honored as the great saint of Qitian. He was very happy, so he held a peach meeting for the monkeys (ID numbered 1 to N). To make it more interesting, Sun Wukong decided to throw the dice. The conference will roll the dice Q times, forming Q instructions, each in the form of ’m a b’, where m is an integer label, and a and b are monkey’s ID. The meaning of each instruction is as follows: 1. If m > 0, send m peaches to each monkey in ID interval [a, b]; 2. If m < 0, remove |m| peaches from each monkey in the ID interval [a, b] (if the number of peaches from any monkey is less than |m|, remove all peaches of the monkey); 3. If m = 0, calculate the sum of peaches of each monkey in the interval [a, b]; now you are invited to preside over the peach conference, can you complete the task according to the requirements of Sun Wukong?

HBC245412SocialDistaHBCingPeach Conference题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
不断挑战自我,才能突破极限!全网最全C++题库,让您在编程道路上越走越远。

标签: HBC245412SocialDistaHBCingPeach Conference题解