No.71 Soroban
Problem Statement
Before computers appeared, the tool for calculation was the "soroban" (abacus).
This time, the problem's theme is that soroban.
Looking at just one column, a typical soroban has 5 beads and can represent 0 to 9.
In one column, the beads are skewered and divided into 1 upper bead and 4 lower beads,
and numbers are represented by taking the number of moved lower beads and further adding 5 for each moved upper bead.
In other words, the upper part can be seen as the carry count of the lower part.
Reference: Wikipedia
http://ja.wikipedia.org/wiki/%E3%81%9D%E3%82%8D%E3%81%B0%E3%82%93#.E5.B8.83.E6.95.B0.E6.B3.95
(Apologies to those who do not know the soroban...)
Then, Ursa came up with a special soroban.
Let the total number of beads usable in one column be $N$, and the numbers of beads used in the upper and lower parts can be chosen freely as long as their total is $N$.
Find the maximum number that can be represented with one column.
Note that the representation is determined only by the raised or lowered state of each bead.
Beads cannot be moved partway, and since the beads of the upper part and of the lower part are each arranged contiguously, the mechanism is such that if the third bead moves, the first and second beads move along with it.
Also, every number from 0 up to the maximum number can be represented uniquely.
Input
$N$
The input is given as an integer.
- $1 \le N \le 1000000 =10^6 $
Output
Find and output the maximum number that can be represented with one column.
Print a newline at the end.
Sample
Sample 1
Input
5
Output
11
This is the same number of beads as a typical soroban, but with 3 beads in the lower part and 2 beads in the upper part, numbers up to 11 can be represented.
Sample 2
Input
19
Output
109
With a good arrangement, numbers up to 109 can be represented.
Sample 3
Input
1000000
Output
250001000000
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。