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
Given an array a of N elements, you need to handle Q types of queries as follows:
r: For each index i in the range l i r update the element ai by dividing it by the smallest prime factor of ai
: Compute and print the sum of ai in the array from index l i r
ik: Update the element at index i to the value k ie ai k
Function description
Complete the DivisorQueries function. This function takes the following parameters and returns the answer
N: An Integer representing the length of array a
Q An Integer representing the number of queries
a An Array of length N representing array a
Queries. A DArray of Q rows and 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
