Logo
(追記) (追記ここまで)

18210번 - Fast Forwarding 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB104828078.431%

문제

Mr. Anderson frequently rents video tapes of his favorite classic films. Watching the films so many times, he has learned the precise start times of his favorite scenes in all such films. He now wants to find how to wind the tape to watch his favorite scene as quickly as possible on his video player.

When the [play] button is pressed, the film starts at the normal playback speed. The video player has two buttons to control the playback speed: The [3x] button triples the speed, while the [1/3x] button reduces the speed to one third. These speed control buttons, however, do not take effect on the instance they are pressed. Exactly one second after playback starts and every second thereafter, the states of these speed control buttons are checked. If the [3x] button is pressed on the timing of the check, the playback speed becomes three times the current speed. If the [1/3x] button is pressed, the playback speed becomes one third of the current speed, unless it is already the normal speed.

For instance, assume that his favorite scene starts at 19 seconds from the start of the film. When the [3x] button is on at one second and at two seconds after the playback starts, and the [1/3x] button is on at three seconds and at five seconds after the start, the desired scene can be watched in the normal speed five seconds after starting the playback, as depicted in the following chart.

Your task is to compute the shortest possible time period after the playback starts until the desired scene starts. The playback of the scene, of course, should be in the normal speed.

입력

The input consists of a single test case of the following format.

t

The given single integer t (0 ≤ t < 250) is the start time of the target scene.

출력

Print an integer that is the minimum possible time in seconds before he can start watching the target scene in the normal speed.

제한

예제 입력 1

19

예제 출력 1

5

예제 입력 2

13

예제 출력 2

5

예제 입력 3

123456789098765

예제 출력 3

85

예제 입력 4

51

예제 출력 4

11

예제 입력 5

0

예제 출력 5

0

예제 입력 6

3

예제 출력 6

3

예제 입력 7

4

예제 출력 7

2

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > ICPC 2019 Asia Yokohama Regional A번

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 2: Greetings from Japan A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /