Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribed

#!/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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

5. What role does power play in determining our cultural spaces?

Answered: 1 week ago

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago