CF311D.Interval Cubing

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

While learning Computational Geometry, Tiny is simultaneously learning a useful data structure called segment tree or interval tree. He has scarcely grasped it when comes out a strange problem:

Given an integer sequence a1,a2,...,ana_{1},a_{2},...,a_{n} . You should run qq queries of two types:

  1. Given two integers ll and rr ( 1<=l<=r<=n1<=l<=r<=n ), ask the sum of all elements in the sequence al,al+1,...,ara_{l},a_{l+1},...,a_{r} .
  2. Given two integers ll and rr ( 1<=l<=r<=n1<=l<=r<=n ), let each element xx in the sequence al,al+1,...,ara_{l},a_{l+1},...,a_{r} becomes x3x^{3} . In other words, apply an assignments al=al3,al+1=al+13,...,ar=ar3a_{l}=a_{l}^{3},a_{l+1}=a_{l+1}^{3},...,a_{r}=a_{r}^{3} .

For every query of type 1, output the answer to it.

Tiny himself surely cannot work it out, so he asks you for help. In addition, Tiny is a prime lover. He tells you that because the answer may be too huge, you should only output it modulo 9554272195542721 (this number is a prime number).

输入格式

The first line contains an integer nn ( 1<=n<=1051<=n<=10^{5} ), representing the length of the sequence. The second line contains nn space-separated integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 0<=ai<=1090<=a_{i}<=10^{9} ).

The third line contains an integer qq ( 1<=q<=1051<=q<=10^{5} ), representing the number of queries. Then follow qq lines. Each line contains three integers tit_{i} ( 1<=ti<=21<=t_{i}<=2 ), lil_{i} , rir_{i} ( 1<=li<=ri<=n1<=l_{i}<=r_{i}<=n ), where tit_{i} stands for the type of the query while lil_{i} and rir_{i} is the parameters of the query, correspondingly.

输出格式

For each 1-type query, print the answer to it per line.

You should notice that each printed number should be non-negative and less than 9554272195542721 .

输入输出样例

  • 输入#1

    8
    1 2 3 4 5 6 7 8
    5
    1 2 5
    2 2 5
    1 2 5
    2 3 6
    1 4 7
    

    输出#1

    14
    224
    2215492
    
首页