Polynomial and Easy Queries
Time limit2sMemory limit256 MB
Maintain an array under range applications of f(x)=2x^2-1 and g(x)=4x^3-3x, and answer point queries modulo 100003.
- Level
Hard9 of 10
- Topics
- Math, Segment tree, Number theory, Combinatorics
- Solved
- No attempts yet
Problem
You are given a sequence of length . Write a program that processes the following three kinds of queries on this sequence.
- : replace every with for all .
- : replace every with for all .
- : print . The answer can grow very large, so print it modulo .
Here and .
Input
The first line contains the length of the sequence and the number of queries .
The second line contains the initial state of the sequence, .
Each of the next lines contains one query in the form above ( or ), in order.
Output
For every query of type 3, print its answer on a line.
Constraints
- For every query, , ,
- At least one query of type 3 is given.