No.8056 Prime Factorization with a Quantum Computer Easy
タグ : / 解いたユーザー数 19
作問者 :
tatyam
Problem Statement
You are given an integer $N$ that is the product of two distinct odd primes $P$ and $Q$. Output $P$ and $Q$. However, you have access to a quantum computer and can query the order of $A$ modulo $N$ for a positive integer $A$ less than $N$ that is coprime to $N$.
Here, for an integer $N\ge 2$ and a positive integer $A$ coprime to $N$, the order of $A$ modulo $N$ is the smallest positive integer $R$ satisfying $A^R \equiv 1 \mod N$.
Input and Output
The first line of the input is given as
$N$
$N$ is a positive integer less than $2^{1024}$, and it is guaranteed to have exactly two distinct odd prime factors. When you query a positive integer $A$ less than $N$ that is coprime to $N$, the order of $A$ modulo $N$ is given as input. The format of a question query is
? A. If you query an $A$ that does not satisfy the conditions, your submission is judged as incorrect. The format of an answer query is
! P Q. It is judged as correct if $P, Q > 1$ and $PQ = N$ are satisfied. There is no limit on the number of queries, but you must output the two distinct prime factors of $N$ within the time limit, which includes the response time of the queries.
Sample
Sample 1
Input
15 1 4 2 4 4 2 4 2
Output
? 1 ? 2 ? 4 ? 7 ? 8 ? 11 ? 13 ? 14 ! 3 5
The order of 1 modulo 15 is 1, the order of 2 is 4, $\cdots$. The prime factors of 15 are 3 and 5.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。