Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives numberaand
Antisimon receives numberb. They also have a heap ofnstones.
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 hasstrictlyless stones left than one needs to take).
Your task is to determine by the givena,bandnwho
wins the game.
Output
If Simon wins, print "0" (without the quotes), otherwise print "1"
(without the quotes).
这样的题目一般都可以找公式的,但是本题却是找不到什么好的公式了。
只有暴力去模拟玩这个游戏了。还好因为其数据不大,故此也许出题者也是没有公式的。
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 题库 101-200 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
Codeforces 1925D Good Trip 题解
codeforces的题解, 动态规划, 228D,
Codeforces 题库 001-100 共~500题 codeforces.com版权所有。 程序可提交至该网站评测。
codeforces编程网站预测分数插件
使用于Google Chrome的Codeforces Enhancer 1.1.2插件安装包。 版本:codeforces enhancer 1.1.2 使用浏览器:Google Chrome
Codeforces 185A - Plant 全测试点49个
codeforces 19 E Fairy 一道比较难的题目的解题报告 推荐阅读
Codeforces global round 10 codes
Codeforces round 678 division 2 codes
Some of the Codeforces problems codes
Codeforces round 678 D2_Codeforces_源码
一个Codeforces、牛客竞赛、AtCoder平台的编程竞赛查询插件,ACMer必备.zip
leetcode题库 简介 本库记录我基于python写过的开源程序。 基于python实现的OJ上的一些题目汇总。 () () () () () () 基于python的专题实现: (10种排序算法) (0-1背包, 完全背包, 多重背包,分组背包等) 拓扑排序
打codeforces的神器
codeforces-js Codeforces JS
lucifer1004大佬的博客cf上分攻略故里大佬的githubcf思维题刷题数:44- (1421)codeforces 676 div2 A,B done
Codeforces Round #723 (Div. 2).md
使用 C# + WPF 开发 --- 还在发愁打了那么多场比赛都没有进入首页么? 还在为了前 5 的 hacker 名额阅读千份代码么? 是的,你没有看错! 这是一个 Edu & Div.3 轮 Open hacking 错误代码自动查找器!...
PDF-CodeForces问题 PDF文件中的CodeForces问题 利用CodeForces提取在这个库中的文件 ,文件夹名代表来自CodeForces网址contests`的ID,每个文件夹包含比赛的问题。 有关CodeForces竞赛的疯狂事实 CodeForces上有937...