CF777A Shell Game 扣碗猜球

题目描述

Bomboslav likes to look out of the window in his room and watch lads outside playing famous shell game. The game is played by two persons: operator and player. Operator takes three similar opaque shells and places a ball beneath one of them. Then he shuffles the shells by swapping some pairs and the player has to guess the current position of the ball.

Bomboslav noticed that guys are not very inventive, so the operator always swaps the left shell with the middle one during odd moves (first, third, fifth, etc.) and always swaps the middle shell with the right one during even moves (second, fourth, etc.).

Let’s number shells from 00 to 22 from left to right. Thus the left shell is assigned number 00 , the middle shell is 11 and the right shell is 22 . Bomboslav has missed the moment when the ball was placed beneath the shell, but he knows that exactly nn movements were made by the operator and the ball was under shell xx at the end. Now he wonders, what was the initial position of the ball?

输入格式

The first line of the input contains an integer nn (1<=n<=2·10^{9}1<=n<=2⋅10次方9 ) — the number of movements made by the operator.

The second line contains a single integer xx ( 0<=x<=2 0<=x<=2 ) — the index of the shell where the ball was found after nn movements.

输出格式

Print one integer from 0 to 2 — the index of the shell where the ball was initially placed //initially是adj初始的

题目解答

注意:这是6个一轮回,英语读明白,看看啥意思。swtich注意有break;deault

switch用法:

switch(expression){
    case constant-expression  :
       statement(s);
       break; // 可选的
    case constant-expression  :
       statement(s);
       break; // 可选的
  
    // 您可以有任意数量的 case 语句
    default : // 可选的
       statement(s);
}

AC代码如下:

using namespace std;
#include <iostream>
#include <cstring>
/*
0次  012
1次  102
2次  120
3次  210
4次  201
5次  021
6次  012
*/ 
int main ()
{
    unsigned long long int n;
    int aa;
    cin>>n>>aa;
    char a[4];
    switch (n%6)
    {
    	case 0:  strcpy(a,"012"); break;
    	case 1:  strcpy(a,"102"); break;
    	case 2:  strcpy(a,"120"); break;
    	case 3:  strcpy(a,"210"); break;
    	case 4:  strcpy(a,"201"); break;
    	case 5:  strcpy(a,"021"); break;
	}
	cout<<a[aa];

	/*if(a[0]-'0'==aa)
	{
		cout<<'0';
	}
	if(a[1]-'0'==aa)
	{
		cout<<'1';
	}
	if(a[2]-'0'==aa)
	{
		cout<<'2';
	}*/	
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯智能台灯

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值