【CodeForces 777A】Shell Game(模拟)
来源:互联网 发布:用户数据挖掘 编辑:程序博客网 时间:2024/04/27 21:39
Shell Game
Problem Description
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 0 to 2 from left to right. Thus the left shell is assigned number 0, the middle shell is 1 and the right shell is 2. Bomboslav has missed the moment when the ball was placed beneath the shell, but he knows that exactly n movements were made by the operator and the ball was under shell x at the end. Now he wonders, what was the initial position of the ball?
The first line of the input contains an integer n (1 ≤ n ≤ 2·109) — the number of movements made by the operator.
The second line contains a single integer x (0 ≤ x ≤ 2) — the index of the shell where the ball was found after n movements.
Output
Print one integer from 0 to 2 — the index of the shell where the ball was initially placed.
思路:模拟找规律
#include<cstdio>using namespace std;int main(){ int n,k; int a[6][3]={0,1,2,1,0,2,1,2,0,2,1,0,2,0,1,0,2,1}; scanf("%d%d",&n,&k); n%=6; printf("%d\n",a[n][k]); return 0;}
- 【CodeForces 777A】Shell Game(模拟)
- Codeforces Round #401 (Div. 2) A. Shell Game(模拟)
- 【codeforces 777A】Shell Game
- Codeforces 777A-Shell Game
- CodeForces 777A Shell Game
- Codeforces 777 A Shell Game
- Shell Game (Codeforces-777A)
- CodeForces - 673A Bear and Game (模拟)水
- Codeforces Round #401 (Div. 2)A. Shell Game(水题~)
- Codeforces Beta Round #35 (Div. 2) / 35A Shell Game(模拟)
- CodeForces 703A Mishka and Game(模拟)
- 【水模拟】#35 A.Shell Game
- codeforces 119A Epic Game(模拟水题)
- Codeforces Round #401 (Div. 2) A.shell game
- Codeforces Round #401 (Div. 2) A. Shell Game
- codeforces - 578B - "Or" Game(模拟)
- Shell Game CodeForces
- codeforces-#468A. 24 Game(构造)
- Qt修炼手册4_信号与槽
- struts2配置文件中标签package标签的属性说明
- mysql学习笔记(一)
- 【codeforces 777B】Game of Credit Cards
- Android中水波纹使用
- 【CodeForces 777A】Shell Game(模拟)
- 双目视觉的标定
- 170224
- SQL高级语句-IN操作符-允许我们在 WHERE 子句中规定多个值。
- 音频自动化测试
- PHP的fsockopen、pfsockopen函数被主机商禁用的解决办法
- IntelliJ IDEA 工具技巧
- (二)Java程序设计之Hello World程序
- sshfs的使用