Question: Write simple python/java program and also explain the logic because i am crying so much and not able to understand anything. First question: RANGE OF

Write simple python/java program and also explain the logic because i am crying so much and not able to understand anything.

First question: RANGE OF QUERIES

You are given an array A with N integers. You are required to answer Q queries of the following type:

L R

Determine the count of distinct prime numbers that divides all the array values from index L to R.

NOTE: Consider 1-based indexing

Input format:

  • The first line contains an integer T denoting the number of test cases.
  • The first line of each test case contains an integer N.
  • The second line of each test case contains N space-separated integers denoting A.
  • The third line contains integer Q.
  • Next, Q lines contain two space-separated integers denoting the queries.

Output Format;

Print the count of distinct prime numbers that divides all the array values from index L to R.

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 Databases Questions!