Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>secret</code> is always between 0 and 10,000,000 inclusive due to the mod by 10,000,001. The observed values are always the last 3 digits of <code>secret</code> (with leading zeros stripped) due to the mod by 1,000. So it's the other digits that are unknown and that only leaves us with 10,001 numbers to iterate over.</p> <p>For each <code>prefix</code> in 0..10,000, we start with <code>secret</code> being constructed from the digits of <code>prefix</code> followed by the first number in the observed sequence with leading zeros. If the list of generated numbers equals the observed list, we have a potential seed. If we end with no potential seeds, we know this must be a wrong machine. If we end with more than one, we don't have enough observations. Otherwise, we generate the next 10 values using the single seed.</p> <p>This runs in O(10,000NT), which is O(20,000,000) for the constraints given. Here's an extract from my solution in C++ (excuse the heavy use of macros, I only ever use them in competitions):</p> <pre><code>int N; cin &gt;&gt; N; int n[N]; REP(i, N) cin &gt;&gt; n[i]; ll poss = 0, seed = -1; FOR(prefix, 0, 10001) { ll num = prefix * 1000 + n[0]; bool ok = true; FOR(i, 1, N) { ll next = getRandomNumber(num); if (next != n[i]) { ok = false; break; } } if (ok) { poss++; seed = prefix * 1000 + n[0]; } } if (poss == 0) { cout &lt;&lt; "Wrong machine" &lt;&lt; endl; } else if (poss &gt; 1) { cout &lt;&lt; "Not enough observations" &lt;&lt; endl; } else { ll num = seed; FOR(i, 1, N) getRandomNumber(num); REP(i, 10) cout &lt;&lt; getRandomNumber(num) &lt;&lt; " "; cout &lt;&lt; endl; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload