Prime Divide
You are given an array A of N numbers.Input Format
You need to perform Q operations. Each operation has one of the two type:
1. 1 l r p: select all numbers between indices l to r which are divisible by p and divide then all by p, here is in set {2, 3 5}.
2. 2 l d: update element at index l to d.
Print the final array after performing all operations.
First line contains single number N denoting size of arrayOutput Format
Second line contains N space seperated numbers A[1] A[2] A[3] ... A[N] denoting elements of array
Third line contains single number Q denoting number of operations
Q following lines contains operations of format
1 l r p or 2 l d
Print in different lines elements of array after performing all operations.Question Video
1. 1 <= N <= 10^5Sample Input
2. 1 <= Q <= 10^5
3. 1 <= l <= r <= N
4. 1 <= A[i], d <= 10^9
5. p belongs to set {2, 3, 5}
5Sample Output
8 9 12 3 5
5
1 1 5 3
2 5 9
1 1 5 3
1 2 5 2
2 3 5
8
1
5
1
3
-
Asked in Companies
-
Related Topics
Video Solution
Code Solution
{ }
{ }
Run