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使其成为一个回文数 ...
随机推荐
- golang 实现轻量web框架
经常看到很多同学在打算使用go做开发的时候会问用什么http框架比较好.其实go的 http package 非常强大,对于一般的 http rest api 开发,完全可以不用框架就可以实现想要的功 ...
- 预装Windows 8系统机型如何进行一键恢复
http://support1.lenovo.com.cn/lenovo/wsi/htmls/detail_20131119141246845.html
- [asp.net web api] HttpStatusCode的使用
摘要 在开放api的时,我们需要返回不同的状态给调用方,以告诉它们当前请求的结果,是成功了还是失败了.当然这种给调用方的反馈有很多种做法,这里就说是web api内置的对Http状态码.http状态码 ...
- 开启PowerDesigner15工具栏上的被禁用掉的图标
PowerDesigner 15 的版本,工具栏上的Inheritance图标默认是禁用的,如下图所示:
- Lucene新版本号对ConjunctionScorer的优化
Lucene 4.0版本号的DocIdSetIterator中没有cost方法,而4.7.0则有这种方法,表示遍历整个DocIdSet的代价,对于DocsEnum就是其长度了,对于Scorer就能够是 ...
- ImageView 设置图片来自:http://blog.csdn.net/lincyang/article/details/6562163
android doc中是这样描述的: public void setImageResource (int resId) 这是其中的一个方法,参数resld是这样: ImageView.setImag ...
- Oracle中索引的使用 索引性能优化调整
索引是由Oracle维护的可选结构,为数据提供快速的访问.准确地判断在什么地方需要使用索引是困难的,使用索引有利于调节检索速度. 当建立一个索引时,必须指定用于跟踪的表名以及一个或多个表列.一旦建立了 ...
- dom4j怎么获得指定名称的节点信息
<?xml version="1.0" encoding="utf-8" ?> <MgUtil> <db_config> & ...
- sql查询前后两位
SQL排名的问题,A这个人在数据库里排第十,怎么查询一个他前面两位,后面两位,包括自己的五条数据,各位有啥高招? DECLARE @table TABLE ( id INT PRIMARY KEY , ...
- Linux下分割、合并PDF(pdftk),用于Linux系统的6款最佳PDF页面裁剪工具
Linux下分割.合并PDF(pdftk),用于Linux系统的6款最佳PDF页面裁剪工具 Linux下分割.合并PDF(pdftk) pdftk http://www.pdflabs.com/doc ...