Pro.ID22218 TitleRoll Over and Die Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22218 AC4 Submit17 Ratio23.53% 时间&空间限制描述A standard die is a cube on which the numbers 1, 2, 3, 4, 5, 6 appear, one per side, and the sum of numbers on opposite sides is always 7. Initially, a single die is placed on a level table in the initial position — the number 1 facing up, 2 facing north, and 3 facing west. In this problem, a roll of a die is not so much a violently tumbling throw as it is a sequence of careful topples, in each of which the die is simply tipped over onto one of the sides previously facing north, east, south or west. Write a program that can input a roll of a die and determine which number is facing up when the roll ends. 输入Each line of the input represents a roll of a die starting from the initial position. Each line contains a string of zero or more characters from the alphabet {N, E, S, W}, respectively representing a successive topple to the north, east, south or west. 输出Description A standard die is a cube on which the numbers 1, 2, 3, 4, 5, 6 appear, one per side, and the sum of numbers on opposite sides is always 7. Initially, a single die is placed on a level table in the initial position — the number 1 facing up, 2 facing north, and 3 facing west. In this problem, a roll of a die is not so much a violently tumbling throw as it is a sequence of careful topples, in each of which the die is simply tipped over onto one of the sides previously facing north, east, south or west. Write a program that can input a roll of a die and determine which number is facing up when the roll ends. Input Each line of the input represents a roll of a die starting from the initial position. Each line contains a string of zero or more characters from the alphabet {N, E, S, W}, respectively representing a successive topple to the north, east, south or west. Output For each line of input, output the number on the die that is facing up after the given roll of the die, starting from the initial position. Sample Input NNNNN Sample Output 5 样例输入NNNNN 样例输出5 提示作者 |