QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 512 MB 満点: 100

#8841. 北北西

統計

我们可以通过重复方向名称:北(north)、南(south)、东(east)和西(west)来描述详细的方向。例如,西北(northwest)是北和西之间的中间方向,北西北(northnorthwest)是北和西北之间的方向。

在本题中,我们按照以下方式描述北和西之间更详细的方向:

  • “north” 表示 0 度。
  • “west” 表示 90 度。
  • 如果方向 $dir$ 表示 $a$ 度,且 $dir$ 中 “north” 和 “west” 出现的总次数为 $n$($n \ge 1$),那么 “north”$dir$(将 “north” 与 $dir$ 连接)表示 $a - \frac{90}{2^n}$ 度,“west”$dir$ 表示 $a + \frac{90}{2^n}$ 度。

你的任务是计算给定方向所表示的角度(以度为单位)。

输入包含多组数据。数据组数不超过 100。

每组数据由一行组成,包含一个表示方向的字符串。你可以假设给定的字符串可以通过连接若干个 “north” 和 “west” 得到,字符串中 “north” 和 “west” 出现的总次数在 1 到 20 之间(含 1 和 20),且给定方向表示的角度在 0 到 90 之间(含 0 和 90)。最后一行仅包含一个字符 ‘#’,表示输入结束。

对于每组数据,如果该方向表示的角度可以表示为整数,则输出该整数;否则,输出其最简分数形式。请遵循样例输出的格式。

样例

输入格式 1

north
west
northwest
northnorthwest
westwestwestnorth
#

输出格式 1

0
90
45
45/2
315/4

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.