sicily 1128. DICE

1128. DICE

Constraints

Time Limit: 1 secs, Memory Limit: 32 MB

Description

Imagine looking at a six-sided die so two sides face east-west, two face north-south, and the last two sides face up-down. You could write down the number of dots on each side in the order: east, west, north, south, up, down.

Normal dice are labeled so that the sum of opposing sides sum to seven. This constraint is sufficient to reduce dice into two categories, "Left handed" and "Right handed." Left handed dice can be oriented so that the east face is 1, the north face is 2, and the down face is 3. Right handed dice can be oriented so that the east face is 1, the north face is 2, and the up face is 3.

In this problem, given the face values of a sequence of dice, you are to determine the handedness of the dice.

Input

The input file will contain a sequence of one or more face descriptions of a die. These will be written as six digits (not separated by white space) on a single line. The numbers will represent (in order) the face values of the east, west, north, south, up, and down faces of the given die.

Output

Other than the standard leader and trailer, the output file simply has the word "left" or "right" for each dice in the input file.

Sample Input

162534162543526134

Sample Output

rightleftleft

题目分析

左手骰子的east, west, north, south, up, and down一定可以变为162543

右手骰子的east, west, north, south, up, and down一定可以变为162534

我们只要确保str[0]==1,str[2]==2,通过查看str[4]即可知道是左手还是右手

策略是: 使1朝向水平面->使1朝向east->使2朝向north

想象有两个手指固定了一个方向,则骰子只能水平或垂直方向旋转

想通第一步对应的变化,注意第二第三步的变化


#include <iostream>

int main()
{
  char temp;
  char cc;
  std::string str;
  while (std::cin >> str) {
    // n s u b => u b s n
    if (str[4] == '1' || str[5] == '1') {
      temp = str[2]; cc = str[3];
      str[2] = str[4]; str[3] = str[5];
      str[5] = temp; str[4] = cc;
    }
    while (str[0] != '1') {
      temp = str[0]; cc = str[1];
      str[0] = str[2]; str[1] = str[3];
      str[3] = temp; str[2] = cc;
    }
    while (str[2] != '2') {
      temp = str[2]; cc = str[3];
      str[2] = str[4]; str[3] = str[5];
      str[5] = temp; str[4] = cc;
  }
    if (str[4] == '4') std::cout << "left" << std::endl;
    else std::cout << "right" << std::endl;
  }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值