아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

험블 수

면접 대비

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

요약
소인수가 2, 3, 5, 7뿐인 수를 작은 것부터 나열할 때 n번째 수를 구해, n에 맞는 영어 서수 접미사를 붙여 출력한다.
난이도

보통10점 중 5점

유형
동적 계획법, 수학, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

소인수가 2, 3, 5, 7 뿐인 수를 험블 수(humble number) 라고 부른다. 수열 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 24, 25, 27, ... 은 처음 20개의 험블 수를 나타낸다.

이 수열의 nn번째 원소를 찾아 출력하는 프로그램을 작성하시오.

입력

입력은 하나 이상의 테스트 케이스로 이루어진다. 각 테스트 케이스는 정수 nn (1≤n≤58421 \le n \le 5842) 하나로 구성된다. 입력은 nn의 값이 00인 줄로 종료되며, 이 줄은 처리하지 않는다.

출력

각 테스트 케이스마다 다음 형식으로 정확히 한 줄을 출력한다.

The <n><접미사> humble number is <number>.

여기서 <number>는 nn번째 험블 수이고, <접미사>는 nn에 해당하는 올바른 영어 서수 접미사("st", "nd", "rd", "th")이다. 예를 들어 1은 "1st", 2는 "2nd", 3은 "3rd"로 쓰지만, 11, 12, 13은 각각 "11th", "12th", "13th"로 쓴다.

예제3

  1. 예제 1

    입력
    1
    2
    3
    4
    11
    12
    13
    21
    22
    23
    100
    1000
    5842
    0
    
    예상 출력
    The 1st humble number is 1.
    The 2nd humble number is 2.
    The 3rd humble number is 3.
    The 4th humble number is 4.
    The 11th humble number is 12.
    The 12th humble number is 14.
    The 13th humble number is 15.
    The 21st humble number is 28.
    The 22nd humble number is 30.
    The 23rd humble number is 32.
    The 100th humble number is 450.
    The 1000th humble number is 385875.
    The 5842nd humble number is 2000000000.
    
  2. 예제 2

    입력
    10
    11
    12
    13
    14
    0
    
    예상 출력
    The 10th humble number is 10.
    The 11th humble number is 12.
    The 12th humble number is 14.
    The 13th humble number is 15.
    The 14th humble number is 16.
    
  3. 예제 3

    입력
    31
    32
    33
    41
    42
    43
    0
    
    예상 출력
    The 31st humble number is 50.
    The 32nd humble number is 54.
    The 33rd humble number is 56.
    The 41st humble number is 81.
    The 42nd humble number is 84.
    The 43rd humble number is 90.