Auxiliary Project | 프로그래밍의 벗 PivotOJ
PivotOJ

Auxiliary Project

시간 제한: 3000ms메모리 제한: 512MB출처: NEERC Northern Subregional 2017BOJ 15131
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Anna has just finished her course project. She has a lot of seven-segment LED displays as leftovers and a small power source. Each display consumes power proportionally to the number of lit segments, e.g. ‘9’ consumes twice more power than ‘7’.

[이미지 1]

Anna wonders what is the maximum possible sum of digits she is able to achieve, if her power source is able to light n segments, and she wants to light exactly n segments.

입력

The single line of the input contains one integer n — the number of segments that should be lit (2 ≤ n ≤ 106).

출력

Output a single integer — the maximum possible sum of digits that can be displayed simultaneously.

힌트

In the first example, a single ‘4’ should be displayed (‘7’ has greater value, but has only three segments). In the second example ‘4’ and ‘7’ should be displayed, in the third one — two ‘7’s.

예제

예제 1

입력
4
출력
4

예제 2

입력
7
출력
11

예제 3

입력
6
출력
14
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.