시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 176 73 71 44.937%

문제

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
W3sicHJvYmxlbV9pZCI6IjY0NjMiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMjlcdWQyYjgiLCJkZXNjcmlwdGlvbiI6IjxwPk4hXHVjNzQwICZxdW90O04gXHVkMzI5XHVkMWEwXHViOWFjXHVjNWJjJnF1b3Q7XHViODVjIFx1Yzc3ZFx1YzczY1x1YmE3MCwgXHVjYzk4XHVjNzRjIE5cdWFjMWNcdWM3NTggXHVjNTkxXHVjNzU4IFx1YzgxNVx1YzIxOFx1Yjk3YyBcdWFjZjFcdWQ1NWMgXHVhYzEyXHVjNzc0XHViMmU0LiBcdWM3NzQgXHViNTRjLCBOXHVjNzQwIFx1Yzc0Y1x1Yzc3NCBcdWM1NDRcdWIyY2MgXHVjODE1XHVjMjE4XHVjNzc0XHVjNWI0XHVjNTdjIFx1ZDU1Y1x1YjJlNC4gXHVjNjA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