[poj2348]Euclid's Game(博弈论+gcd)】的更多相关文章

Euclid's Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9033   Accepted: 3695 Description Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser o…
假设当前b>a. 一.b%a==0 必胜 二.b<2*a,当前我们没有选择的余地,若下一步是必胜(最终能到情况一),则当前必败:反之,当前必胜. 三.b>2*a,假设x是使得b-ax<a的整数,考虑一下从b中减去a(x-1)的情况,例如对于(4,19)则减去12. 此时,接下来的状态就成了前边讲过的没有选择余地的情况二,若该状态是必败态的话,当前状态就是必胜态. 若该状态是必胜态的话,其下一步是唯一确定的,因此是必败态,所以我们可以直接到达此态. ∴情况三是必胜态. ∴先达到情况一…
http://poj.org/problem?id=2348 顺便说,必应翻译真的好用,比谷歌翻译好用100倍. 很难判断这道题的具体博弈类型. 有两种写法,一种是找规律,一种是推理得到关系后循环(或递归)处理.两种写法都能在题目下面的discuss中找到. 1.找规律,我在这里直接复制了discuss中大神算出的sg函数表(在考试中这种写法是很值得借鉴的,这里就体现出代码能力的重要了,找规律天下第一!). 我算了一下前 30 × 30 的 Sprague-Grundy 函数表,如下: 0 1…
思路:两个数a和b,总会出现的一个局面是b,a%b,这是必然的,如果a>=b&&a<2*b,那么只有一种情况,直接到b,a%b.否则有多种情况. 对于a/b==1这种局面,只可能到b,a%b,没有选择.而a/b>=2的话,先手可以选择由谁面对b,a%b这样的局势,先手在a/b>=2的局面必胜 代码如下: #include<stdio.h> #include<iostream> #include<algorithm> #includ…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8313   Accepted: 3374 Description Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser of the two numb…
基础博弈的小结:http://blog.csdn.net/acm_cxlove/article/details/7854530 经典翻硬币游戏小结:http://blog.csdn.net/acm_cxlove/article/details/7854534 经典的删边游戏小结:http://blog.csdn.net/acm_cxlove/article/details/7854532 五篇国家集训队论文: 张一飞: <由感性认识到理性认识——透析一类搏弈游戏的解答过程 > 王晓珂:<…
I collect and make up this pseudocode from the book: <<Introduction to the Design and Analysis of Algorithms_Second Edition>> _ Anany LevitinNote that throughout the paper, we assume that inputs to algorithms fall within their specified ranges…
Exif是可交换图像文件的缩写,是专门为数码相机的照片设定的,可以记录数码照片的属性和拍摄数据 ////调用 //string strFile="fffff.jpg";//文件名 //System.Drawing.Bitmap bmp = new Bitmap(strFile); //EXIF.EXIFextractor er = new EXIF.EXIFextractor(ref bmp, "\n"); //Console.Write(strFile + &qu…
这一讲我们集中解说类和他的一些特性.首先我们从自己定义一个有理数类来開始. 在C语言中有一个keyword: struct ,用来创建一个结构体类型.可是在C++中这个关键的含义就不只如此了,以下我们能够看下演示样例: /// Represent a rational number. struct rational { int numerator; ///< numerator gets the sign of the rational value int denominator; ///<…
图论 图论解题报告索引 DFS poj1321 - 棋盘问题 poj1416 - Shredding Company poj2676 - Sudoku poj2488 - A Knight's Journey poj1724 - ROADS(邻接表+DFS) BFS poj3278 - Catch That Cow(空间BFS) poj2251 - Dungeon Master(空间BFS) poj3414 - Pots poj1915 - Knight Moves poj3126 - Prim…