F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Development Value

Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 791    Accepted Submission(s): 196


Problem Description
StarCraft 2 (SC2) is a famous game. More and more people fall in love with this game.

As a crazy fan of SC2, Ahua (flower fairy) play it day and night. Recently, he found that the most important part of being a top player of SC2 is economic development, which means you should get as much mine as possible by training SCVs (space construction vehicle) to collect mine. Train a SCV at ith second costs Ci units of mine. After training, this SCV can collect Di units of mine each second. Training a SCV needs one second of time.

Based on that, he composes a formula to evaluate the development in a time span from xth second to yth second. Assume at xth second, Ahua has no SCV and mine. He trains one SCV at each second during xth second and yth second (the mount of mine can be negative, so that he always can train SCV). Each SCV will collect some amount of mines for Ahua in each second after it was trained. At ith second Ahua has Mi units of mine in total. The development value is defined as sum(Mi) (x ¡Ü i ¡Ü y). Now he asks you to help him calculate the development value. To make it more interesting, Ahua can apply following operations:

Cost x y z: the cost of training a SCV between xth second to yth second will increase by z units of mine. i.e. Ci for x ¡Ü i ¡Ü y will increase by z.

Collect x y z: each SCV trained between xth second and yth second can collect z more mines every second after it has been trained. i.e. Di for x ¡Ü i ¡Ü y will increase by z.

Query x y: output the development value between xth second and yth second.
 

Input
First line of the input is a single integer T (T ¡Ü 10), indicates there are T test cases.
For each test case, the first line is an integer N (1 ¡Ü N ¡Ü 100000), means the maximum time you should deal with.

Following N lines, each contain two integers Ci and Di (0 ¡Ü Ci, Di ¡Ü 100000), the cost and collect speed of SCV training in ith second initially as described above.

The next line is an integer Q (1 ¡Ü Q ¡Ü 10000), the number of operations you should deal with. Then Q lines followed, each line will be ¡°Cost x y z¡±, "Collect x y z¡± or ¡°Query x y¡±.
1 ¡Ü x ¡Ü y ¡Ü N, 0 ¡Ü z ¡Ü 100000
 

Output
For each test case, first output ¡°Case k: ¡° in a single line, k is the number of the test case, from 1 to T. Then for each "Q x y", you should output a single line contains the answer mod 20110911.
 

Sample Input
1 5 1 3 2 3 3 1 2 2 3 3 5 Query 1 3 Cost 2 2 1 Query 1 3 Collect 1 1 5 Query 1 3
 

Sample Output
Case 1: 2 0 15
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-25 06:25:17, Gzip enabled