A Kth Root Subarray
Practice
3.3 (7 votes)
Advanced data structures
Data structures
Xor
Hashing algorithm
Lazy propagation in interval/segment trees
Number theory
Problem
91% Success 3351 Attempts 50 Points 2.5s Time Limit 256MB Memory 1024 KB Max Code
The problem statement is simple.
You are given an array A of N integers. You have to answer Q queries of three types.
- 1 L R : Determine if the subarray [ AL , AL+1 , AL+2 , ..... AR ] is special or not.
- 2 L R X Y : Multiply all the elements of the subarray [ AL , AL+1 , AL+2 , ..... AR ] by XY.
- 3 L R X : Reset all the elements of the subarray [ AL , AL+1 , AL+2 , ..... AR ] to value X.
Let \(val=\prod_{i=L}^R A_i\) = Product of the subarray [ AL , AL+1 , AL+2 , ..... AR ]
A subarray is special if \(\sqrt[K]{val}\) is a integer . In other words the Kth root of product of the subarray should be a integer.
Input Format
First line contains three integers N K Q.
Next line contains N integers A1 , A2 , A3 , ..... AN .
Next Q lines contains one of the three types of queries.
Constraints
- 1 <= N <= 105
- 1 <= Q <= 5*104 ,
- 1 <= Ai , X , Y <= 106
- 1 <= L<=R <= N
- 1 <= K <= 30000
Output
For each query of type 1 , print Yes if the subarray is special else No
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
2 votes
Tags:
Lazy Propagation in Interval/Segment TreesData StructuresBit manipulationAdvanced Data Structures
Points:50
Tags:
Hard
Points:50
3 votes
Tags:
Advanced Data StructuresData StructuresString AlgorithmsLazy Propagation in Interval/Segment TreesHashing algorithm
Editorial
Login to unlock the editorial