HomeWork20251117

HomePage | Memberswill go by tor | RecentChanges | Join |

a

Short answer. otherwise there won't be part b. Given R, the function P=P(R)P=P(R) and Q=Q(R)Q=Q(R), as said, are fast. So we can use the algorithm of the following part, which is fast too.

Long answer. Given RR, the candidates of the P,QP,Q pair population is only 1, so few to guess.

b

Given NN. Starting guess RNR \leq \sqrt{N} the largest integer, then following steps.

  1. Get the P=P(R)P=P(R) and Q=Q(R)Q=Q(R). If N=PQN=P Q, then done.
  2. Try RP1R \leftarrow P -1, but remembering the PP already collected previously is the new Q=R+1Q=R+1, go to step 1 for searching a lower PP while there is still room for PP.
  3. Now the 'searching lower' fails so a similar 'searching high' starting from RNR \geq \sqrt{N}, and hope the asker was not lying about NN then there shall be an answer

In this naïve algorithm, the results from step 2 will have PQ<NP Q &lt; N and the results from step 3 will have PQ>NP Q &gt;N so they deem not the answer. So the correct answer shall be out in step 1 already.

Overall, it is still polynomial time of the size of the digits