#K9751. Prime Command Execution

    ID: 39099 Type: Default 1000ms 256MiB

Prime Command Execution

Prime Command Execution

You are given an array representing the strengths of soldiers. The array consists of n elements. You will also receive m commands, where each command is one of the following types:

  • 1 X Y: Update the soldier at position X (1-indexed) to have a new strength Y.
  • 2 L R: Query the number of soldiers with prime number strengths in the range from L to R (inclusive).

A number is said to be prime if it is greater than 1 and has no positive divisors other than 1 and itself. Process all m commands in the order they are given and for each query command, print the result on a new line.

Note: The positions in the commands are 1-indexed.

inputFormat

The input is provided via stdin and consists of multiple lines:

  1. The first line contains two integers n and m --- the number of soldiers and the number of commands.
  2. The second line contains n integers, representing the initial strengths of the soldiers.
  3. Each of the next m lines contains a command in one of the formats: "1 X Y" for updates or "2 L R" for queries.

outputFormat

For each query command (of type "2 L R"), output a single integer on a new line representing the count of soldiers with prime number strengths in the range specified.

## sample
6 5
6 10 3 5 7 15
2 1 6
1 4 11
2 3 5
2 1 3
2 2 4
3

3 1 2

</p>