sobhanbera / algorithms

Dive into algorithms, data structures, and competitive programming solutions in multiple languages. Active since Hacktoberfest 2020!
https://github.com/sobhanbera
MIT License
28 stars 85 forks source link

Arrays and Queries #266

Open Rupa-Rd opened 9 months ago

Rupa-Rd commented 9 months ago

This issue is about [Algo/DS Name/Question Name](link to resource for the Algo/DS/Question)

Problem Statement

Given the array of length n denoting set of numbers and q denotes the number of queries The queries of three types:

  1. l r : For each i with l <= i <= r a[i] = a[i]/d, where d is the smallest prime factor of a[i]
  2. l r : Print the sum of all a[i] with l <= i <= r
  3. i k : Set a[i] = k

Input Format: -> The first line denotes n and q -> The second line contains n number of integers -> The third line contains q number of Queries in the above mentioned format

Output Format: Print the values when the Query type 2 is called

Sample Test Case: Input: 5 3 10 2 8 7 6 2 1 4 1 1 4 2 1 4 Output : 27 11

Explanation: For Query [2 1 4] : 10 + 2 + 8 + 7 = 27 For Query [1 1 4] : [5 1 4 1 6] For Query [2 1 4] : 5 + 1 + 4 + 1 = 11

Source : This is a most recent question asked in BNY Mellon Challenge so I couldn't able to find any source for this question

Rupa-Rd commented 9 months ago

Hi, @sobhanbera Could you assign this issue to me?

Smritigit1202 commented 8 months ago

please assign the issue