QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB

#23949. 散歩

Statistiques

問題文

JOI 君は,一直線の道路上で散歩をしている.

JOI 君は以下の行動を行動 A → 行動 B → 行動 A → … のように交互に繰り返す.

  • 行動 A:$3\text{ m}$ 前に進む.
  • 行動 B:$2\text{ m}$ 後ろに戻る.

行動 A と行動 B を合わせて $X$ 回行ったとき,はじめの位置から何 $\text{m}$ 前に移動したことになるか?

制約

  • $1 \le X \le 100$.
  • $X$ は整数である.

入力

入力は以下の形式で与えられる.
$X$

出力

はじめの位置から前に移動した距離が何 $\text{m}$ かを,単位 ($\text{m}$) を除いて出力せよ.

答え以外は何も出力しないこと.(入力を促す文章なども出力しないこと.)

解答形式については,練習問題やその解答例 を参考にしても良い.


入力例 1

3

出力例 1

4
  • $3\text{ m}$ 前に進む.
  • $2\text{ m}$ 後ろに戻る.
  • $3\text{ m}$ 前に進む.

という計 $3$ 回の行動をするため,はじめの位置から $4 (= 3 - 2 + 3)\text{ m}$ 前に移動したことになる.従って $4$ を出力する.


入力例 2

6

出力例 2

3
  • $3\text{ m}$ 前に進む.
  • $2\text{ m}$ 後ろに戻る.
  • $3\text{ m}$ 前に進む.
  • $2\text{ m}$ 後ろに戻る.
  • $3\text{ m}$ 前に進む.
  • $2\text{ m}$ 後ろに戻る.

という計 $6$ 回の行動をするため,はじめの位置から $3 (= 3 - 2 + 3 - 2 + 3 - 2)\text{ m}$ 前に移動したことになる.従って $3$ を出力する.


入力例 3

1

出力例 3

3
  • $3\text{ m}$ 前に進む.

という計 $1$ 回の行動をするため,はじめの位置から $3\text{ m}$ 前に移動したことになる.従って $3$ を出力する.


入力例 4

37

出力例 4

21

はじめの位置から $21\text{ m}$ 前に移動したことになるため,$21$ を出力する.


入力例 5

100

出力例 5

50

はじめの位置から $50\text{ m}$ 前に移動したことになるため,$50$ を出力する.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.