【codeforces 777A】Shell Game
【题目链接】:http://codeforces.com/contest/777/problem/A
【题意】
奇数次操作交换1,2位置的东西;
偶数此操作交换2,3位置的东西
给你操作的次数,和最后的位置;
问你一开始的位置在哪里.
【题解】
/*
一开始在0位置
1 2 3 4 5 6
1 2 2 1 0 0
这就是一个循环,到了第6次操作又回到了初始状态;
n%6 == 1 - > 1
== 2 ->2
...
== 0 ->0
->最终的位置就和n%6的值有关;
在1位置
1 2 3 4 5 6
0 0 1 2 2 1
第6次操作就回到了初始状态;
在2位置
1 2 3 4 5 6
2 1 0 0 1 2
第6次操作回到初始状态
枚举一开始的位置就好;看看哪个和答案符合;
*/
【完整代码】
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%lld",&x)
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int dx[9] = { 0,1,-1,0,0,-1,-1,1,1 };
const int dy[9] = { 0,0,0,-1,1,-1,1,-1,1 };
const double pi = acos(-1.0);
const int N = 110;
int zero[7] = { -1,1 ,2, 2, 1 ,0 ,0 };
int one[7] = { -1,0, 0, 1, 2, 2, 1 };
int two[7] = { -1,2, 1, 0, 0, 1, 2 };
LL n;
int x;
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
rel(n);
rei(x);
LL temp = n % 6;
if (temp == 0)
temp = 6;
if (zero[temp] == x)
{
puts("0");
return 0;
}
if (one[temp] == x)
{
puts("1");
return 0;
}
if (two[temp] == x)
{
puts("2");
return 0;
}
return 0;
}
【codeforces 777A】Shell Game的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
- 【Codeforces 670C】 Cinema
[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...
- 【codeforces 515D】Drazil and Tiles
[题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...
随机推荐
- [置顶]
WebService学习总结(4)——第三方webService服务调用
互联网上面有很多的免费webService服务,我们可以调用这些免费的WebService服务,将一些其他网站的内容信息集成到我们的Web应用中显示,下面就以获取天气预报数据和查询国内手机号码归属地为 ...
- [置顶]
WebService学习总结(1)——WebService相关概念
一.序言 大家或多或少都听过 WebService(Web服务),有一段时间很多计算机期刊.书籍和网站都大肆的提及和宣传WebService技术,其中不乏很多吹嘘和做广告的成 分.但是不得不承认的是W ...
- Maven学习总结(15)——Maven 项目中pom.xml详解
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2 ...
- ajax对服务端发送请求
//兼容处理获取ajax对象 var req = ''; if (window.XMLHttpRequest) req = new XMLHttpRequest(); else req = ...
- Android Gradle统一依赖管理
目的: 避免在依赖包出新版本时,需要对每个module中的build.gradle文件都进行修改(如appcompat-v7包),使用这种方式即只需一次修改. 方法一 在项目的根目录创建一个gradl ...
- Android Set与List之间转化
List list = new ArrayList(set); Set set = new HashSet(list); //但是有一点,转换当中可能要丢失数据,尤其是从list转换到set的时候,因 ...
- Linear to physical address translation with support for page attributes
Embodiments of the invention are generally directed to systems, methods, and apparatuses for linear ...
- C语言深度剖析-----内存管理的艺术
动态内存分配 为什么使用动态内存分配 例:记录卖出的商品 卖出商品最多只能记录1000个 两种改进的方法 都需要动态内存分配 第二种方法需要重置内存 calloc和realloc realloc重置内 ...
- 10.4 android输入系统_框架、编写一个万能模拟输入驱动程序、reader/dispatcher线程启动过程源码分析
1. 输入系统框架 android输入系统官方文档 // 需FQhttp://source.android.com/devices/input/index.html <深入理解Android 卷 ...
- iOS INVALID_USER_SCODE 定位 用户安全码未通过
iOS 高德地图API不能定位及INVALID_USER_SCODE问题,有需要的朋友可以参考下. 一.在使用高德地图的API的时候,没有办法实现定位,在这里说一下在真机测试的时候出现没法定位应该注意 ...