시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 181 75 72 48.000%

문제

N!은 "N 팩토리얼"로 읽으며, 처음 N개의 양의 정수를 곱한 값이다. 이때, N은 음이 아닌 정수이어야 한다. 예를 들면 다음과 같다.

 N       N! 
 0       1 
 1       1 
 2       2 
 3       6 
 4      24 
 5     120 
10 3628800

N을 입력 받아 0이 아닌 마지막 자리를 구하는 프로그램을 작성하시오. 예를 들어, 5!의 경우에 정답은 2이다. 5! = 120이고, 2는 0이 아닌 마지막 자리이기 때문이다.

입력

입력은 10000을 넘지 않는 음이 아닌 정수로 이루어져 있으며, 한 줄에 하나씩 주어진다. 각각의 정수는 N이며, 이를 입력받아 N!의 0이 아닌 마지막 자리를 출력해야 한다.

출력

입력으로 주어진 각각의 N에 대해서, 1~5열에는 N을 오른쪽 정렬로 출력하고, 6~9열에는 " -> ", 10열에는 N!의 0이 아닌 마지막 자리를 출력한다.

예제 입력 1

1
2
26
125
3125
9999

예제 출력 1

    1 -> 1
    2 -> 2
   26 -> 4
  125 -> 8
 3125 -> 2
 9999 -> 8
W3sicHJvYmxlbV9pZCI6IjY0NjMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMjlcdWQyYjgiLCJkZXNjcmlwdGlvbiI6IjxwPk4hXHVjNzQwICZxdW90O04gXHVkMzI5XHVkMWEwXHViOWFjXHVjNWJjJnF1b3Q7XHViODVjIFx1Yzc3ZFx1YzczY1x1YmE3MCwgXHVjYzk4XHVjNzRjIE5cdWFjMWNcdWM3NTggXHVjNTkxXHVjNzU4IFx1YzgxNVx1YzIxOFx1Yjk3YyBcdWFjZjFcdWQ1NWMgXHVhYzEyXHVjNzc0XHViMmU0LiBcdWM3NzRcdWI1NGMsIE5cdWM3NDAgXHVjNzRjXHVjNzc0IFx1YzU0NFx1YjJjYyBcdWM4MTVcdWMyMThcdWM3NzRcdWM1YjRcdWM1N2MgXHVkNTVjXHViMmU0LiBcdWM2MDhcdWI5N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