No.1992 Tendon Walk
タグ : / 解いたユーザー数 267
作問者 :
MasKoaTS
/ テスター :
Problem Statement
Currently, Koa-san is stopped at the point with coordinate $0$ on a number line.
From now on, Koa-san will perform the following actions A and B in the order "A → A → B → B → A → B → B" as $1$ set, and will perform $100$ sets in a row.
Action A : Move $2$ in the positive direction of the number line, then stop at the destination point.
Action B : Move $1$ in the negative direction of the number line, then stop at the destination point.
Find the distance traveled by Koa-san until stopping for the first time at the point with coordinate $X$ on the number line.
Here, during each action, Koa-san never stops while moving along the number line.
Constraints
$2 \leq X \leq 10$
$X$ is an integer
Input
The input is given in the following format.
$X$
The $1$st line contains $X$.
Output
Print the answer on $1$ line, followed by a newline.
Sample
Sample 1
Input
6
Output
14
By performing each action, Koa-san moves and stops at coordinates
$0 \to 2 \to 4 \to 3 \to 2 \to 4 \to 3 \to 2 \to 4 \to 6 \to \cdots$
in this order.
Therefore, the distance traveled until stopping for the first time at the point with coordinate $6$ is
$|2| + |2| + |-1| + |-1| + |2| + |-1| + |-1| + |2| + |2| = 14$
.
Sample 2
Input
3
Output
5
By performing each action, Koa-san moves and stops at coordinates $0 \to 2 \to 4 \to 3 \to \cdots$ in this order.
Note that when performing action A for the $2$nd time, Koa-san passes through the point with coordinate $3$ but does not stop there.
Sample 3
Input
10
Output
34
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。