Computer Science, asked by abhichauhan5682, 8 months ago

Indumati has been given an array consisting of A ones and B zeroes.
One operation is defined as follows:
• Select any C elements of the array, delete them from the array and add append their average (the irreducible fractional form) to the array.
It is guaranteed that A+B-1 is a multiple of C-1.
Indumati repeats this operation until only 1 number (also an irreducible fraction) is left in the array.
Your task is to find the number of distinct values this fraction can take, modulo 10° +7.​

Answers

Answered by jpseducons
1

Answer:

Indumati and Fraction Problem Description Indumati has been given an array consisting of A ones and B zeroes One operation is defined as follows: . Select any C elements of the array, delete them from the array and add append their average (the irreducible fractional form) to the array, It is guaranteed that A+B-1 is a multiple of C-1. Indumati repeats this operation until only 1 number (also an irreducible fraction) is left in the array, Your task is to find the number of distinct values this fraction can take, modulo 10'+7. Problem Constraints 1 <= A, B <= 2000 2 <= C <= 2000 It is guaranteed that A+B-1 is a multiple of C-1 Input Format The first argument is A. The second argument is B. The third argument is C. Output Format Your function should return a single integer, the number of distinct values the final fraction can take, modulo 10° +7 Example Input Input 1: A: 1 B: 1 Input 2 22 min 135 sec 0/6 Attempted Example Input Input 1: B: 1 C: 2 Input 2: A: 2 B: 2 C: 2 Example Output Output 1: 1 Output 2: Example Explanation Explanation 1: The array is [e, 1] initially. Indumati takes 2 numbers and 1, deletes them and adds their average, 1/2 to the array, Now the array is [1/2] and now she can't perform any operation Explanation 2 There are five possible values for the final fraction: 1/4, 1/2, 3/8, 5/8 and 3/4. 3/8 will be left if we: • Delete 0 and 1 and append 1/2 to the array, • Delete 1/2 and 1 and append 3/4 to the array, • Delete 0 and 3/4 and append 3/8 to the array,

Similar questions