Additive Primes

면접 대비

시간 제한1초메모리 제한2048 MB

요약
정수 n이 주어질 때 n이 소수인지와 각 자리 숫자의 합이 소수인지를 판별해 해당 분류를 출력한다.
난이도

쉬움10점 중 3점

유형
수학, 정수론, 구현
정답자
아직 제출이 없습니다

문제

A prime number is an integer nn (n≥2n \ge 2) such that nn cannot be formed as the product of two other integers smaller than nn. In other words, a number is prime if its factors are only one and itself. An integer which is greater than 22 and is not prime is called a composite number.

An additive prime in base-1010 is a number which is both prime and the sum of its digits forms a prime number. For example, 2323 is an additive prime, since 2323 is prime, and 2+3=52 + 3 = 5 is also prime, but 1313 is not, since 1+3=41 + 3 = 4, and 44 is not prime.

입력

Input consists of a single integer nn (2≤n≤231−12 \le n \le 2^{31} - 1).

출력

Output "ADDITIVE PRIME" if the number is an additive prime. Output "PRIME, BUT NOT ADDITIVE" if the number is prime, but not an additive prime. Output "COMPOSITE" otherwise.

예제3

  1. 예제 1

    입력
    61
    
    예상 출력
    ADDITIVE PRIME
    
  2. 예제 2

    입력
    17
    
    
    예상 출력
    PRIME, BUT NOT ADDITIVE
    
  3. 예제 3

    입력
    141
    
    예상 출력
    COMPOSITE