#P11621. Weighted Point Operations
Weighted Point Operations
Weighted Point Operations
You are given a plane with integer coordinates, where each lattice point initially has a weight of 0. There are a total of operations. There are two types of operations:
- Modification Operation: Given integers , , , and , increase the weight of every lattice point satisfying
by .
- Query Operation: Given integers , , , and , compute the sum of weights of all lattice points satisfying
and output the result modulo .
All mathematical formulas are in LaTeX format. HTML tags may be used in this description.
inputFormat
The first line contains an integer , the number of operations. Each of the following lines represents an operation. An operation starting with 1
indicates a modification operation and is followed by four integers: , , , and . An operation starting with 2
indicates a query operation and is followed by four integers: , , , and .
outputFormat
For each query operation, output a single line containing the computed sum modulo .
sample
3
1 1 1 3 5
2 1 3 1 3
2 2 5 2 5
30
5
</p>