问题2303--Can you answer these queries?

2303: Can you answer these queries?

时间限制: 4 Sec  内存限制: 512 MB
提交: 3  解决: 2
[提交] [状态] [讨论版] [命题人:]

题目描述

A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value of endurance. For every attack of our secret weapon, it could decrease the endurance of a consecutive part of battleships by make their endurance to the square root of it original value of endurance. During the series of attack of our secret weapon, the commander wants to evaluate the effect of the weapon, so he asks you for help.
You are asked to answer the queries that the sum of the endurance of a consecutive part of the battleship line.
Notice that the square root operation should be rounded down to integer.
大意:许多邪恶的战舰在战斗前排成一列。我们的指挥官决定使用我们的秘密武器消灭战舰。每艘战舰都可以标记一个耐力值。对于我们秘密武器的每次攻击,它都会使战舰的续航力降至其原始续航力的平方根,从而降低其连续部分的续航力。在我们秘密武器的一系列攻击中,指挥官想评估武器的效果,所以他请求你的帮助。
你被要求回答的问题是,战列舰线连续部分的耐力总和。
请注意,平方根运算应四舍五入为整数。

输入

The input contains several test cases, terminated by EOF.
  For each test case, the first line contains a single integer N, denoting there are N battleships of evil in a line. (1 <= N <= 100000)
  The second line contains N integers Ei, indicating the endurance value of each battleship from the beginning of the line to the end. You can assume that the sum of all endurance value is less than 263.
  The next line contains an integer M, denoting the number of actions and queries. (1 <= M <= 100000)
  For the following M lines, each line contains three integers T, X and Y. The T=0 denoting the action of the secret weapon, which will decrease the endurance value of the battleships between the X-th and Y-th battleship, inclusive. The T=1 denoting the query of the commander which ask for the sum of the endurance value of the battleship between X-th and Y-th, inclusive.
大意:输入包含几个测试用例,由EOF终止。
对于每个测试用例,第一行包含一个整数N,表示一行中有N艘邪恶的战舰。(1<=N<=100000)
第二行包含N个整数Ei,表示每艘战舰从行首到行尾的续航力值。你可以假设所有耐力值的总和小于263。
下一行包含一个整数M,表示操作和查询的数量。(1<=M<=100000)
对于以下M行,每行包含三个整数T、X和Y。T=0表示秘密武器的动作,这将降低第X艘和第Y艘战列舰之间的战列舰的续航力值。T=1表示指挥官的询问,要求计算战舰在第X次和第Y次之间的续航力值之和。

输出

For each test case, print the case number at the first line. Then print one line for each query. And remember follow a blank line after each test case.
大意:对于每个测试用例,在第一行打印用例编号。然后为每个查询打印一行。请记住,在每个测试用例后填写一个空白行。

样例输入 Copy

10
1 2 3 4 5 6 7 8 9 10
5
0 1 10
1 1 10
1 1 5
0 5 8
1 4 8

样例输出 Copy

Case #1:
19
7
6

提示

来源 HDU 4027

来源/分类