CF679E.Bear and Bad Powers of 42

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Limak, a bear, isn't good at handling queries. So, he asks you to do it.

We say that powers of 4242 (numbers 1,42,1764,...1,42,1764,... ) are bad. Other numbers are good.

You are given a sequence of nn good integers t1,t2,...,tnt_{1},t_{2},...,t_{n} . Your task is to handle qq queries of three types:

  1. 1 i — print tit_{i} in a separate line.
  2. 2 a b x — for set tit_{i} to xx . It's guaranteed that xx is a good number.
  3. 3 a b x — for increase tit_{i} by xx . After this repeat the process while at least one tit_{i} is bad.

You can note that after each query all tit_{i} are good.

输入格式

The first line of the input contains two integers nn and qq ( 1<=n,q<=1000001<=n,q<=100000 ) — the size of Limak's sequence and the number of queries, respectively.

The second line of the input contains nn integers t1,t2,...,tnt_{1},t_{2},...,t_{n} ( 2<=ti<=1092<=t_{i}<=10^{9} ) — initial elements of Limak's sequence. All tit_{i} are good.

Then, qq lines follow. The ii -th of them describes the ii -th query. The first number in the line is an integer typeitype_{i} ( 1<=typei<=31<=type_{i}<=3 ) — the type of the query. There is at least one query of the first type, so the output won't be empty.

In queries of the second and the third type there is 1<=a<=b<=n1<=a<=b<=n .

In queries of the second type an integer xx ( 2<=x<=1092<=x<=10^{9} ) is guaranteed to be good.

In queries of the third type an integer xx ( 1<=x<=1091<=x<=10^{9} ) may be bad.

输出格式

For each query of the first type, print the answer in a separate line.

输入输出样例

  • 输入#1

    6 12
    40 1700 7 1672 4 1722
    3 2 4 42
    1 2
    1 3
    3 2 6 50
    1 2
    1 4
    1 6
    2 3 4 41
    3 1 5 1
    1 1
    1 3
    1 5
    

    输出#1

    1742
    49
    1842
    1814
    1822
    43
    44
    107
    

说明/提示

After a query 3 2 4 42 the sequence is 40,1742,49,1714,4,172240,1742,49,1714,4,1722 .

After a query 3 2 6 50 the sequence is 40,1842,149,1814,104,182240,1842,149,1814,104,1822 .

After a query 2 3 4 41 the sequence is 40,1842,41,41,104,182240,1842,41,41,104,1822 .

After a query 3 1 5 1 the sequence is 43,1845,44,44,107,182243,1845,44,44,107,1822 .

首页