시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 626 336 309 58.857%

문제

상근이는 보통 사람들이 사는 것과는 조금 다른 삶을 사는 사람이다. 상근이는 이런 사람들의 시선이 부담스럽기 때문에, 자신만의 숫자를 개발하기로 했다. 바로 그 이름은 팩토리얼 진법이다. 팩토리얼 진법은 각 자리에 올 수 있는 숫자는 0부터 9까지로 10진법과 거의 비슷하다. 하지만, 읽는 법은 조금 다르다. 팩토리얼 진법에서는 i번 자리의 값을 ai×i!로 계산한다. 즉, 팩토리얼 진법에서 719는 10진법에서 53과 같다. 그 이유는 7×3! + 1×2! + 9×1! = 53이기 때문이다.

팩토리얼 진법으로 작성한 숫자가 주어졌을 때, 10진법으로 읽은 값을 구하는 프로그램을 작성하시오. 

입력

입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, 길이가 최대 5자리인 팩토리얼 진법 숫자가 주어진다. 입력의 마지막 줄에는 0이 하나 주어진다.

출력

각 테스트 케이스에 대해서, 입력으로 주어진 팩토리얼 진법 숫자를 10진법으로 읽은 값을 출력한다.

예제 입력 1

719
1
15
110
102
0

예제 출력 1

53
1
7
8
8
W3sicHJvYmxlbV9pZCI6IjU2OTIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQzMjlcdWQxYTBcdWI5YWNcdWM1YmMgXHVjOWM0XHViYzk1IiwiZGVzY3JpcHRpb24iOiI8cD5cdWMwYzFcdWFkZmNcdWM3NzRcdWIyOTQgXHViY2Y0XHVkMWI1IFx1YzBhY1x1Yjc4Y1x1YjRlNFx1Yzc3NCBcdWMwYWNcdWIyOTQgXHVhYzgzXHVhY2ZjXHViMjk0IFx1Yzg3MFx1YWUwOCBcdWIyZTRcdWI5NzggXHVjMGI2XHVjNzQ0IFx1YzBhY1x1YjI5NCBcdWMwYWNcdWI3OGNcdWM3NzRcdWIyZTQuIFx1YzBjMVx1YWRmY1x1Yzc3NFx1YjI5NCBc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GlnaXRzLCByZXByZXNlbnRpbmcgYSBudW1iZXIgaW4gQUNNIG5vdGF0aW9uLiBUaGUgc3RyaW5nIGRvZXMgbm90IGhhdmUgbGVhZGluZyB6ZXJvcy48XC9wPlxyXG5cclxuPHA+VGhlIGxhc3QgdGVzdCBjYXNlIGlzIGZvbGxvd2VkIGJ5IGEgbGluZSBjb250YWluaW5nIG9uZSB6ZXJvLjxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPkZvciBlYWNoIHRlc3QgY2FzZSBvdXRwdXQgYSBzaW5nbGUgbGluZSBjb250YWluaW5nIHRoZSBkZWNpbWFsIHJlcHJlc2VudGF0aW9uIG9mIHRoZSBjb3JyZXNwb25kaW5nIEFDTSBudW1iZXIuPFwvcD5cclxuIiwiaGludCI6IiIsIm9yaWdpbmFsIjoiMSIsInByb2JsZW1fbGFuZ19jb2RlIjoiXHVjNjAxXHVjNWI0In1d

출처

ACM-ICPC > Regionals > Latin America > Latin America Regional Contests 2010 PB번

  • 문제의 오타를 찾은 사람: bachjs
  • 문제를 번역한 사람: baekjoon