Chili Sauce
Time limit1sMemory limit512 MB
Each spice level maps to a distinct capsaicin value written in base 7 using only digits 0, 1, 2; given such a value, find the level it corresponds to.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Implementation
- Solved
- No attempts yet
Problem
Yonggwang loves 72 chili sauce. Yonggwang is deciding which chili sauce to buy. This chili sauce has spice levels from 1 to 727,272. The 72 chili sauce is produced at a factory in Building 72 of Inha University, and one bottle of sauce is made from a combination of base capsaicins, each equal to a power of 7. Each base capsaicin can be used at most twice. Each level is determined by the capsaicin content obtained by adding one or more distinct powers of 7, each at most twice. A capsaicin content does not by itself indicate a spice level. However, the more capsaicin a 72 chili sauce contains, the higher its spice level. For example, with one base capsaicin containing 7 to the 0th power of capsaicin and two base capsaicins containing 7 to the 1st power of capsaicin, you can make a 72 chili sauce containing 15 units of capsaicin. The spice level of this sauce is 7. For spice level 1, the sauce contains 1 unit of capsaicin.
Oh! Yonggwang has chosen a chili sauce! We know the capsaicin content of the chili sauce Yonggwang chose. Let's figure out its spice level!
Input
The first line gives the capsaicin content c. Capsaicin contents exceeding spice level 727,272 are not given, and no error occurs in the process of producing 72 chili sauce at the chili sauce factory.
Output
On the first line, output the spice level of the chili sauce.