Composite Function and Queries 2
Time limit2sMemory limit512 MB
Maintain a function f on {1..N} under updates to f(1) and queries asking for the m-fold iterate f^m(x).
- Level
Hard8 of 10
- Topics
- Graph, Binary search, Prefix sum, Math
- Solved
- No attempts yet
Problem
You are given the values of a function . Write a program that handles the following queries.
1 x: change the value of to .2 m x: print the value of .
Here is the function obtained by composing with itself times: , and for every positive integer , .
Input
The first line gives the positive integer .
The second line gives the initial values in order.
The third line gives the number of queries .
Each of the next lines contains one query.
Output
Print the result of each type 2 query, one per line.
Constraints
- For a type 1 query,
- For a type 2 query, and