Sicily 1128. DICE

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

162534
162543
526134

Sample Output

right
left
left


O(∩_∩)O~~ Just do it! 骰子游戏

#include <iostream>
#include <string>

using namespace std;

int main()
{
    char Temp; string str;

    while (cin >> str)
    {
        if (str[4] == '1' || str[5] == '1')
        {    绕Y轴逆时针翻转,确保‘1’位于东西南北之一
            Temp = str[4];
            str[4] = str[0];
            str[0] = str[5];
            str[5] = str[1];
            str[1] = Temp;
        }
        while (str[0] != '1')
        {    绕Z轴逆时针旋转
            Temp = str[0];
            str[0] = str[2];
            str[2] = str[1];
            str[1] = str[3];
            str[3] = Temp;
        }
        while (str[2] != '2')
        {
             绕X轴逆时针旋转
            Temp = str[2];
            str[2] = str[5];
            str[5] = str[3];
            str[3] = str[4];
            str[4] = Temp;
        }
        if (str[4] == '3')
            cout << "right" << endl;
        else
            cout << "left" << endl;
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值