CF1114F.Please, another Queries on Array?

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

You are given an array a1,a2,,ana_1, a_2, \ldots, a_n .

You need to perform qq queries of the following two types:

  1. "MULTIPLY l r x" — for every ii ( lirl \le i \le r ) multiply aia_i by xx .
  2. "TOTIENT l r" — print φ(i=lrai)\varphi(\prod \limits_{i=l}^{r} a_i) taken modulo 109+710^9+7 , where φ\varphi denotes Euler's totient function.

The Euler's totient function of a positive integer nn (denoted as φ(n)\varphi(n) ) is the number of integers xx ( 1xn1 \le x \le n ) such that gcd(n,x)=1\gcd(n,x) = 1 .

输入格式

The first line contains two integers nn and qq ( 1n41051 \le n \le 4 \cdot 10^5 , 1q21051 \le q \le 2 \cdot 10^5 ) — the number of elements in array aa and the number of queries.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai3001 \le a_i \le 300 ) — the elements of array aa .

Then qq lines follow, describing queries in the format given in the statement.

  1. "MULTIPLY l r x" ( 1lrn1 \le l \le r \le n , 1x3001 \le x \le 300 ) — denotes a multiplication query.
  2. "TOTIENT l r" ( 1lrn1 \le l \le r \le n ) — denotes a query on the value of Euler's totient function.

It is guaranteed that there is at least one "TOTIENT" query.

输出格式

For each "TOTIENT" query, print the answer to it.

输入输出样例

  • 输入#1

    4 4
    5 9 1 2
    TOTIENT 3 3
    TOTIENT 3 4
    MULTIPLY 4 4 3
    TOTIENT 4 4
    

    输出#1

    1
    1
    2
    

说明/提示

In the first example, φ(1)=1\varphi(1) = 1 for the first query, φ(2)=1\varphi(2) = 1 for the second query and φ(6)=2\varphi(6) = 2 for the third one.

首页