logo AlgoBeat OnlineJudge
登录 注册

#217587. [ICPC 2019 Yinchuan R] Pot!!

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Little Q is very sleepy, and he really needs some coffee to make him awake. At this time, Little L brings a pot to Little Q, and he states the pot as follows.

For a prime number , if and , we say .

The pot is very special that it can make everyone awake immediately.

Now Little L provides integers to Little Q, each of which is initially. After that, Little L shows types of queries:

  • MULTIPLY l r x: For every (), multiply by ().
  • MAX l r: Calculate the value of

    where is prime.

Now you need to perform queries of these two types of queries described above.

If you perform a “MULTIPLY” query, you don't need to output anything.

If you perform a “MAX” query, you need to output a line like ANSWER y, where the value you've calculated.

输入格式

The first line contains two integers and , the number of integers and the number of queries.

Each of the next lines contains one type of query described above.

输出格式

For each “MAX” query, output one line in the format of ANSWER y, where the value you have calculated.

样例

样例输入 1

5 6
MULTIPLY 3 5 2
MULTIPLY 2 5 3
MAX 1 5
MULTIPLY 1 4 2 
MULTIPLY 2 5 5 
MAX 3 5

样例输出 1

ANSWER 1
ANSWER 2

数据范围与提示

If and are non-zero integers, or more generally, non-zero elements of an integral domain, it is said that divides if there exists an integer , or an element of the integral domain, such that , and this is written as .