Cryptography

면접 대비

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

요약
10^10 이하의 정수 n이 주어질 때 소수인지 판별하여 소수이면 SAFE, 아니면 BROKEN을 출력한다.
난이도

쉬움10점 중 3점

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

문제

Dave has just completed the Massive Open Online Course (MOOC) Cryptography on the popular website Coursera.org. Eager to create his own cryptography system -- against the advise of the teacher Dan Boneh to never, ever, ever implement your own crypto-system -- he searches for a SKP (Special Key Prime) A SKP is a prime that is preferably a large number, because the larger the number the more secure it is to use as a key. Remember that a prime is a number that is only divisible by 1 and itself. For example 2 is a prime because it's only divisible by 1 and 2. 15 however is not a prime since beside 1 and 15, also 3 and 5 happen to divide this number. The number 1 is considered to not be a prime.

Luckily his friend Trudy is quite good at guessing large numbers that could be prime. Your task is given a number by Trudy, to decide whether this is actually a prime or not.

입력

You are given a number 0≤n≤10100 \leq n \leq 10^{10}, the number that Trudy has guessed for Dave to use as a SKP.

출력

You should output "SAFE" (without the quotes) iff the number nn is a prime, else your program should output "BROKEN" (again, without the quotes).

예제3

  1. 예제 1

    입력
    2
    
    예상 출력
    SAFE
    
  2. 예제 2

    입력
    15
    
    예상 출력
    BROKEN
    
  3. 예제 3

    입력
    104729
    
    예상 출력
    SAFE