codeforces Epic Game 题解
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and
Antisimon receives number b. They also have a heap of nstones.
The players take turns to make a move and Simon starts. During a move a player should take from the heap the number of stones equal to the greatest common divisor of the fixed number he has received and the number of stones left in the heap. A player loses
when he cannot take the required number of stones (i. e. the heap has strictly less stones left than one needs to take).
Your task is to determine by the given a, b and n who
wins the game.
The only string contains space-separated integers a, b and n (1 ≤ a, b, n ≤ 100)
— the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile.
If Simon wins, print "0" (without the quotes), otherwise print "1"
(without the quotes).
3 5 9
0
1 1 100
1
这种题目一般都能够找公式的,可是本题却是找不到什么好的公式了。
仅仅有暴力去模拟玩这个游戏了。还好由于其数据不大。故此或许出题者也是没有公式的。
namespace{ int GCD(int a, int b)
{
if (1 == a || b == 1) return 1;
while (b)
{
int t = b;
b = a%b;
a = t;
}
return a;
}
} void EpicGame()
{
int a, b, c, d;
cin>>a>>b>>c;
bool goGame = 0;
while (c >= 0)
{
if (goGame) d = GCD(b, c);
else d = GCD(a, c);
c -= d;
goGame = !goGame;
}
cout<<goGame;
}
codeforces Epic Game 题解的更多相关文章
- Codeforces Round #556 题解
Codeforces Round #556 题解 Div.2 A Stock Arbitraging 傻逼题 Div.2 B Tiling Challenge 傻逼题 Div.1 A Prefix S ...
- Codeforces Round #569 题解
Codeforces Round #569 题解 CF1179A Valeriy and Deque 有一个双端队列,每次取队首两个值,将较小值移动到队尾,较大值位置不变.多组询问求第\(m\)次操作 ...
- Codeforces Round #557 题解【更完了】
Codeforces Round #557 题解 掉分快乐 CF1161A Hide and Seek Alice和Bob在玩捉♂迷♂藏,有\(n\)个格子,Bob会检查\(k\)次,第\(i\)次检 ...
- CFEducational Codeforces Round 66题解报告
CFEducational Codeforces Round 66题解报告 感觉丧失了唯一一次能在CF上超过wqy的机会QAQ A 不管 B 不能直接累计乘法打\(tag\),要直接跳 C 考虑二分第 ...
- codeforces CF475 ABC 题解
Bayan 2015 Contest Warm Up http://codeforces.com/contest/475 A - Bayan Bus B - Strongly Connected Ci ...
- Codeforces Round #542 题解
Codeforces Round #542 abstract I决策中的独立性, II联通块染色板子 IIIVoronoi diagram O(N^2 logN) VI环上距离分类讨论加取模,最值中的 ...
- Codeforces Choosing Laptop 题解
这题实在是太水了,具体看注释 蒟蒻的方法是一边找过时的电脑一边比大小 蒟蒻不才,只会C++ 其实还会free basic,但它已经过时了 附: 本题洛谷网址 Codeforces网址 希望蒟蒻的题解能 ...
- Codeforces 381 简要题解
做的太糟糕了...第一题看成两人都取最优策略,写了个n^2的dp,还好pre-test良心(感觉TC和CF的pretest还是很靠谱的),让我反复过不去,仔细看题原来是取两边最大的啊!!!前30分钟就 ...
- Codeforces 863 简要题解
文章目录 A题 B题 C题 D题 E题 F题 G题 传送门 简要题解?因为最后一题太毒不想写了所以其实是部分题解... A题 传送门 题意简述:给你一个数,问你能不能通过加前导000使其成为一个回文数 ...
随机推荐
- JDK篇
卸载系统自带的jdk 使用以下命令查看是否已经安装了jdk rpm -qa|grep java rpm -qa|grep jdk 如果已经安装了可能会得到下面的结果: java-1.4.2-gcj ...
- Namespace declaration statement has to be the very first statement in the script
php 中 Namespace declaration statement has to be the very first statement in the script 错误解决方法: 在PHP文 ...
- dea工具debug断点红色变成灰色
没事别瞎点,禁用了断点当然不走了
- mysqld --debug=d:t:i:O:n --user=mysql (源码调试)
--debug=d:t--debug=d:f,main,subr1:F:L:t,20--debug=d,input,output,files:n--debug=d:t:i:O,\\mysqld.tra ...
- IOS快速入门
http://www.cnblogs.com/wellsoho/p/4313312.html
- objective-c block 详解 转
Block Apple 在C, Objective-C, C++加上Block這個延申用法.目前只有Mac 10.6 和iOS 4有支援.Block是由一堆可執行的程式組成,也可以稱做沒有名字的F ...
- [翻译] AGPhotoBrowser 好用的图片浏览器
AGPhotoBrowser 好用的图片浏览器 https://github.com/andreagiavatto/AGPhotoBrowser A photo browser for iOS6 a ...
- #line 的作用是改变当前行数和文件名称
#line 的作用是改变当前行数和文件名称,它们是在编译程序中预先定义的标识符命令的基本形式如下: #line number["filename"]其中[]内的文件名可以省略. ...
- spring事务管理器的源码和理解
原文出处: xieyu_zy 以前说了大多的原理,今天来说下spring的事务管理器的实现过程,顺带源码干货带上. 其实这个文章唯一的就是带着看看代码,但是前提你要懂得动态代理以及字节码增强方面的知识 ...
- 【hihoCoder】【挑战赛#12】
模拟+枚举+模拟……+构造 QAQAQQQ rank12求杯子! A 顺子 ……模拟题,分类讨论一下就好了……比如当前四张牌是不是同一花色……是不是连续的四张牌,如果是连续的四张牌,是不是两边的……( ...