CF1114F.Please, another Queries on Array?
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a1,a2,…,an .
You need to perform q queries of the following two types:
- "MULTIPLY l r x" — for every i ( l≤i≤r ) multiply ai by x .
- "TOTIENT l r" — print φ(i=l∏rai) taken modulo 109+7 , where φ denotes Euler's totient function.
The Euler's totient function of a positive integer n (denoted as φ(n) ) is the number of integers x ( 1≤x≤n ) such that gcd(n,x)=1 .
输入格式
The first line contains two integers n and q ( 1≤n≤4⋅105 , 1≤q≤2⋅105 ) — the number of elements in array a and the number of queries.
The second line contains n integers a1,a2,…,an ( 1≤ai≤300 ) — the elements of array a .
Then q lines follow, describing queries in the format given in the statement.
- "MULTIPLY l r x" ( 1≤l≤r≤n , 1≤x≤300 ) — denotes a multiplication query.
- "TOTIENT l r" ( 1≤l≤r≤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 for the first query, φ(2)=1 for the second query and φ(6)=2 for the third one.