Shell Game (类似找骰子游戏)

Time Limit: 2000MS Memory Limit: 65536K 64bit IO Format: %I64d& %I64u

[Submit [GoBack  [Status]

Description

Today the «Z» city residents enjoy a shell game competition. Theresidents are gathered on the main square to watch thebreath-taking performance. The performer puts 3 non-transparentcups upside down in a row. Then he openly puts a small ball underone of the cups and starts to shuffle the cups around very quicklyso that on the whole he makes exactly 3 shuffles. After that thespectators have exactly one attempt to guess in which cup theythink the ball is and if the answer is correct they get a prize.Maybe you can try to find the ball too?

Input

The first input line contains an integer from 1 to 3 — index ofthe cup which covers the ball before the shuffles. The followingthree lines describe the shuffles. Each description of a shufflecontains two distinct integers from 1 to 3 — indexes of the cupswhich the performer shuffled this time. The cups are numbered fromleft to right and are renumbered after each shuffle from left toright again. In other words, the cup on the left always has index1, the one in the middle — index 2 and the one on the right — index3.

Output

In the first line output an integer from 1 to 3 — index of thecup which will have the ball after all the shuffles.

Sample Input

Input
1

1 2

2 1

2 1

Output
2

Input
1

2 1

3 1

1 3

Output
2
 
   
#include<iostream>
using namespace std;
int main()
{
        int n,a1,b1,a2,b2,a3,b3;
        freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout); 
 
        while(cin>>n)
        {

                cin>>a1>>b1;
                cin>>a2>>b2;
                cin>>a3>>b3;
                if(a1==n||b1==n)
                {
                        if(a1==n) n=b1;
                        else  n=a1;
                }
                if(a2==n||b2==n)
                {
                        if(a2==n) n=b2;
                        else  n=a2;
                }
                
                if(a3==n||b3==n)
                {
                        if(a3==n) n=b3;
                        else  n=a3;
                }
                cout<<n<<endl;
        }
        return 0;


}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值