Logo
(追記) (追記ここまで)

33537번 - Breaking the Cipher 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB32271890.000%

문제

It has already been years since Alice moved into her new house in the countryside, but only a week ago she suddenly found a mysterious safe, requiring a secret combination to unlock, hidden in her basement. She jumped onto the internet to ask strangers for clues and she received a message from a mysterious man called Bob. He included the combination to Alice's safe, but noted that he had encrypted it with the RSA algorithm using Alice's public key. On the internet you find that the RSA algorithms works as follows:

Key generation:

  1. Choose two distinct prime numbers $p$ and $q$.
  2. Compute $n = pq$.
  3. Compute $\phi(n) = \phi(p)\cdot \phi(q) = (p - 1)\cdot (q - 1) = n - (p + q - 1),ドル where $\phi$ is Euler's totient function.
  4. Choose an integer $e$ such that 1ドル < e < \phi(n)$ and gcd$(e, \phi(n)) = 1$; i.e., $e$ and $\phi(n)$ are coprime.
  5. Determine $d$ as $d \equiv e^{-1} \pmod{\phi(n)}$; i.e., $d \cdot e \equiv 1 \pmod{\phi(n)}$.

Encryption:

Suppose that Bob would like to send message $M$ to Alice. He then computes the ciphertext $C,ドル using Alice's public key $e,ドル corresponding to \begin{equation*} C \equiv M^e \pmod{n} \end{equation*}

Decryption:

Alice can recover $M$ from $C$ by using her private key exponent $d$ by computing \begin{equation*} M \equiv C^d \pmod{n} \end{equation*} Additionally, Alice has learned that the following congruence could prove to be useful for the decryption process: \begin{equation*} (a \cdot b) \mod{n} \equiv ((a \mod{n}) \cdot (b \mod{n})) \mod{n} \end{equation*}

Alice has already chosen the integers $p,ドル $q,ドル and $e$ accordingly and needs your help to decrypt the message $C$ she has received from Bob.

입력

The input to this problem is structured as follows: The first line contains three integers, 1ドル < p, q, e < 1000,ドル respectively. The second line contains one integer $C,ドル the encrypted secret combination to Alice's safe.

출력

One line with the (decrypted) combination $M$ to Alice's safe.

제한

예제 입력 1

751 337 739
735

예제 출력 1

15075

예제 입력 2

181 677 739
567

예제 출력 2

11662

예제 입력 3

467 823 397
802

예제 출력 3

368133

힌트

출처

University > Delft University of Technology > Freshmen Programming Contest 2016 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /