CT884

RSA Messenger: Generate Two Large Primes for the Kingdom's Encryption

MediumAcceptance: 0.0%

The Royal Cryptographer of Prime City paced the stone corridor, wax seal in hand. The kingdom's RSA encryption system requires two large prime numbers to generate a secure key, and the old primes have been compromised by enemy spies. A new pair must be found before the midnight deadline. "Find the two largest primes within a given range," the cryptographer instructs, unrolling a scroll of numbers. "These will form the foundation of our new encryption key. The larger the primes, the stronger the cipher. But hurry ÔÇö the enemy's codebreakers are already at work." Given a range [L, R], find the two largest prime numbers within that range. Output them in descending order (largest first). If fewer than two primes exist in the range, output "None". The cryptographer's constraints are strict: 2 <= L <= R <= 10^6, and R - L <= 10^4 Verified examples from the cryptographer's test scrolls: Input: 10 30 Output: 29 23 Input: 1 10 Output: 7 5 The torches flicker as the midnight bell approaches. The kingdom's secrets depend on your speed and accuracy. Find the primes, and the messages will be safe for another generation.

Constraints:

2 <= L <= R <= 10^6, R - L <= 10^4

Tags:

prime numbers number-theory rsa math
Loading...
Test Cases:No test cases
No test cases available.