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.