Even Odd Queries
Practice
3.3 (18 votes)
Ad Hoc
Easy
Implementation
Problem
42% Success 8906 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array \(Arr\) of size N, containing integers. You have to answer Q queries where each query is of the form :

K L R :- If \(K=0\), then you have to find the probability of choosing an even number from the segment \([L,R]\) (both Inclusive) in the array \(Arr\).

K L R :- If \( K=1\), then you have to find the probability of choosing an odd number from the segment \([L,R]\) (both Inclusive) in the array \(Arr\).

For each query print two integers p and q which represent the probability \(p/q\). Both p and q are reduced to the minimal form.

If p is 0 or p is equal to q print \(p/q\) alone.

Constraints:

  • \(1 ≤ T ≤ 10\)
  • \(1 ≤ N,Q ≤ 10000\)
  • \(1 ≤ Arr_i ≤ 1000000\)
  • \(0 ≤ K ≤ 1\)
  • \(1 ≤ L ≤R≤ N\)

Format of the input file:
First line : T i.e Number of testcases.
For each testcase :
First line : Two space separated integers N and Q.
Second line : N space separated integers denoting the array .
Next Q lines ; Three space separated integers K L and R.

Format of the output file:
Output the answer to each query in a separate line.

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
6 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementationMath
Points:20
26 votes
Tags:
ApprovedBasic ProgrammingEasyOpen
Points:20
33 votes
Tags:
Ad-HocApprovedBasic ProgrammingEasyOpen