Jeff loves to develop code for random scenarios. Today Jeff started playing with a couple of Arrays A and B, each of size N. Initially A is filled with zeros. Jeff filled B with random numbers. Jeff...


cse


Jeff loves to develop code for random scenarios. Today Jeff started playing with a<br>couple of Arrays A and B, each of size N. Initially A is filled with zeros. Jeff filled B<br>with random numbers. Jeff visits each index i (1 <= i <= N) in random order. When at<br>i, he selects another random indexj such that j is greater or equal to i. He then<br>increments A[i], A[i+1], A[i+2] ... Alj] by 1. Finally, if for any index i, A[i] is greater than<br>B[1], he then throws away that array A. For a given B, calculate the number of<br>different arrays A, that Jeff can end up with. Two arrays are called different if there<br>exists an index where the arrays have different values. Help Jeff in creating a C++<br>code that prints a single line containing the required answer modulo 109 + 7.<br>Sample Test Case:<br>1<br>111<br>Result:<br>2<br>

Extracted text: Jeff loves to develop code for random scenarios. Today Jeff started playing with a couple of Arrays A and B, each of size N. Initially A is filled with zeros. Jeff filled B with random numbers. Jeff visits each index i (1 <= i=""><= n)="" in="" random="" order.="" when="" at="" i,="" he="" selects="" another="" random="" indexj="" such="" that="" j="" is="" greater="" or="" equal="" to="" i.="" he="" then="" increments="" a[i],="" a[i+1],="" a[i+2]="" ...="" alj]="" by="" 1.="" finally,="" if="" for="" any="" index="" i,="" a[i]="" is="" greater="" than="" b[1],="" he="" then="" throws="" away="" that="" array="" a.="" for="" a="" given="" b,="" calculate="" the="" number="" of="" different="" arrays="" a,="" that="" jeff="" can="" end="" up="" with.="" two="" arrays="" are="" called="" different="" if="" there="" exists="" an="" index="" where="" the="" arrays="" have="" different="" values.="" help="" jeff="" in="" creating="" a="" c++="" code="" that="" prints="" a="" single="" line="" containing="" the="" required="" answer="" modulo="" 109="" +="" 7.="" sample="" test="" case:="" 1="" 111="" result:="">

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here