#C3638. Prime Pair Sum Problem

    ID: 47087 Type: Default 1000ms 256MiB

Prime Pair Sum Problem

Prime Pair Sum Problem

Given an integer \(n\), your task is to find two prime numbers \(p\) and \(q\) such that \(p+q=n\). If more than one pair exists, choose the pair with the smallest absolute difference \(|p-q|\). If there are still multiple solutions, choose the pair where the smaller prime is the smallest. If no such pair exists, output an empty array, denoted as [].

Examples:

  • For \(n=10\), the answer is 5 5 because \(5+5=10\) and the difference \(|5-5|=0\) is minimal.
  • For \(n=12\), the answer is 5 7 since \(5+7=12\).
  • For \(n=4\), the answer is 2 2.
  • For \(n=20\), the answer is 7 13.
  • For \(n=1\) or \(n=27\), no valid pair exists so output [].

inputFormat

The input consists of a single integer \(n\) (\(0 \le n \le 10^6\)). The number is provided via standard input.

outputFormat

If there exists a valid pair of prime numbers \(p\) and \(q\) such that \(p+q=n\), output the two numbers separated by a space via standard output. Otherwise, output [].

## sample
10
5 5