簡單 時間限制:3 s記憶體限制:256 MB

Online Judge - 10235 - Simply Emirp

來源代碼:UVa
CPE歷屆試題CPE一星
前往提交 ↓

An integer greater than 1 is called a prime number if its only positive divisors (factors) are 1 and itself. Prime numbers have been studied over the years by a lot of mathematicians. Applications of prime numbers arise in Cryptography and Coding Theory among others.

Have you tried reversing a prime? For most primes, you get a composite (43 becomes 34). An Emirp (Prime spelt backwards) is a Prime that gives you a different Prime when its digits are reversed.
For example, 17 is Emirp because 17 as well as 71 are Prime.

In this problem, you have to decide whether a number N is Non-prime or Prime or Emirp. Assume that 1 < N < 1000000. Interestingly, Emirps are not new to NTU students. We have been boarding 199 and 179 buses for quite a long time!

輸入說明

Input consists of several lines specifying values for N.

輸出說明

資料格式說明

For each N given in the input, output should contain one of the following:

  1. ‘N is not prime.’, if N is not a Prime number.

  2. ‘N is prime.’, if N is Prime and N is not Emirp.

  3. ‘N is emirp.’, if N is Emirp.

輸入輸出範例

範例 1

範例輸入
17
18
19
179
199
範例輸出
17 is emirp.
18 is not prime.
19 is prime.
179 is emirp.
199 is emirp.

範例 2

範例輸入
2
4
11
13
23
範例輸出
2 is prime.
4 is not prime.
11 is prime.
13 is emirp.
23 is prime.

範例 3

範例輸入
101
103
107
121
373
999999
範例輸出
101 is prime.
103 is prime.
107 is emirp.
121 is not prime.
373 is prime.
999999 is not prime.
開啟討論
開啟紀錄

登入後即可撰寫程式、測試範例及提交解答。

登入