2018 ACM 国际大学生程序设计竞赛上海大都会赛重现赛 H - A Simple Problem with Integers (线段树,循环节)
链接:https://ac.nowcoder.com/acm/contest/163/H
来源:牛客网
链接:https://ac.nowcoder.com/acm/contest/163/H来源:牛客网
时间限制:C/C++ 2秒,其他语言4秒
空间限制:C/C++ 262144K,其他语言524288K
64bit IO Format: %lld
题目描述
You have N integers A1, A2, ... , AN. You are asked to write a program to receive and execute two kinds of instructions:
\1. C a b means performing Ai = (Ai2 mod 2018) for all Ai such that a ≤ i ≤ b.
\2. Q a b means query the sum of Aa, Aa+1, ..., Ab. Note that the sum is not taken modulo 2018.
输入描述:
The first line of the input is T(1≤ T ≤ 20), which stands for the number of test cases you need to solve.The first line of each test case contains N (1 ≤ N ≤ 50000).The second line contains N numbers, the initial values of A1, A2, ..., An. 0 ≤ Ai < 2018. The third line contains the number of operations Q (0 ≤ Q ≤ 50000). The following Q lines represents an operation having the format "C a b" or "Q a b", which has been described above. 1 ≤ a ≤ b ≤ N.
输出描述:
For each test case, print a line "Case #t:" (without quotes, t means the index of the test case) at the beginning.You need to answer all Q commands in order. One answer in a line.
示例1
输入
[复制](javascript:void(0)