Programming contests

ECN programozó csapatverseny, 2017. május 13.

May 13, 2017 10:10 AM – May 13, 2017 3:10 PM

Random Points

It is given a random number generator implemented in C programming language:

  1. unsigned int m_w = 11;
  2. unsigned int m_z = 173;
  3. unsigned int M = 2001;
  4. unsigned int myrandom() {
  5.     m_z = 36969 * (m_z & 65535) + (m_z >> 16);
  6.     m_w = 18000 * (m_w & 65535) + (m_w >> 16);
  7.     return ((m_z << 16) + m_w) % M;
  8. }
download as text file

A & B – bitwise AND operator
A >> n – bitwise right shift operator
A << n – bitwise left shift operator
A % M – modulo operator
A = B – assignment

Using the given random number generator, generate N = 100 000 distinct points in the plane, having integer coordinates between 0 and 2000. The numbers are generated until the desired number of distinct points is reached.

Compute the shortest distance between the generated points.

A point in the plane is generated by two consecutive calls to the myrandom() function:

unsigned int x = myrandom();
unsigned int x = myrandom();

Input Specification

No input is required.

Output Specification

The shortest distance, followed by a newline character.

University of Debrecen; Faculty of Informatics; v. 03/01/2019