QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB

#23949. 散步

Statistics

題目描述

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.