Question: #!/bin/python3 import math import os import random import re import sys # # Complete the 'findLargest' function below. # # The function is expected to

 #!/bin/python3 import math import os import random import re import sys# # Complete the 'findLargest' function below. # # The function isexpected to return an INTEGER_ARRAY. # The function accepts following parameters: #

#!/bin/python3

import math import os import random import re import sys

# # Complete the 'findLargest' function below. # # The function is expected to return an INTEGER_ARRAY. # The function accepts following parameters: # 1. INTEGER s # 2. INTEGER a # 3. INTEGER b # 4. INTEGER m # 5. INTEGER n # 6. INTEGER k #

def findLargest(s, a, b, m, n, k): # Write your code here

if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w')

first_multiple_input = input().rstrip().split()

s = int(first_multiple_input[0])

a = int(first_multiple_input[1])

b = int(first_multiple_input[2])

m = int(first_multiple_input[3])

second_multiple_input = input().rstrip().split()

n = int(second_multiple_input[0])

k = int(second_multiple_input[1])

result = findLargest(s, a, b, m, n, k)

fptr.write(' '.join(map(str, result))) fptr.write(' ')

fptr.close()

Jack is implementing a pseudo random number generator (RNG), and wants to assess some statistics on it. His RNG is paramterised by 4 numbers: s,a,b and m. The RNG defines a sequence of integers: {xi} for i0 such that x0=s and for all i>0 : xi+1=(xi2+axi+b)modm Given positive integers n and k, he wants to determine the k largest values produced from the first n values generated (i.e. from {x0,,xn1} ). Write a program to output those top k values. Input Format 2 Lines: Line 1: s a b m Line 2: nk Constraints 0s1091a1091b1092m21091n1071k105 Output Format From the input, the RNG parameters are s=3,a=2,b=1,m=100, and n=8 and k=5, so we are looking for the largest 5 values from the first 8 . The table below illustrates how the first 8 values are generated. So the first 8 values are {3,16,89,0,1,4,25,76}. The largest 5 values are 16,89,4,25,76 so we output them in increasing order to report the

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!