7022 - Goldbach and Euler   

Description

古典數學家很常以信件來討論各自的猜想,以下是尤拉(Euler)寄給哥德巴契(Goldbach)的一封信

“That every number which is resolvable into two prime numbers can be resolved into as many prime numbers as you like, can be illustrated and confirmed by an observation which you have formerly communicated to me, namely that every even number is a sum of two primes, and since (n-2) is also a sum of two prime numbers, n must be a sum of three, and also four prime numbers, and so on. If, however, n is an odd number, then it is certainly a sum of three prime numbers, since (n-1) is a sum of two prime numbers, and can therefore be resolved into as many prime numbers as you like. However, that every number is a sum of two primes, I consider a theorem which is quite true, although I cannot demonstrate it.”

-- Euler to Goldbach, 1742

Euler認為所有偶數的數字都可以拆成兩個質數相加,但畢竟沒有經過證明,
而且有些奇數也有可能是兩個質數相加,請你設計一個程式,
判斷某個數字n是不是可以寫N = p1+p2,(p1, p2為相異兩質數)

Input

每一行代表一個測試資料,最多有10,000行
每行都有一個正整數 (0 < n <= 100,000,000)

Output

對於每一個測試資料,有以下兩種輸出情形:
n is not the sum of two primes!
n is the sum of p1 and p2.
如果一個存在多組n = p1 + p2,則輸出p1 < p2且p2-p1的值要最小的答案

Sample Input  Download

Sample Output  Download

Tags




Discuss