Question: Least Prime Factor 2 Given an array a of N elements, you need to handle Q types of queries as follows: 3 1 1 r:

Least Prime Factor
2
Given an array a of N elements, you need to handle Q types of queries as follows:
3
11r: For each index i in the range l <= i <= r update the element a_{i} by dividing it by the smallest prime factor of a_{i}
21: Compute and print the sum of a_{i} in the array from index l <= i <= r
5
3 ik: Update the element at index i to the value k. i.e. a_{i}= k
6
Function description
Complete the Divisor_Queries function. This function takes the following 4 parameters and returns the answer
7
N: An Integer representing the length of array a
8
Q. An Integer representing the number of queries
a. An Array of length N representing array a
Queries. A 2D-Array of Q rows and 3 columns representing the three types of Queries

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!