HDU 5512 Meeting 博弈论】的更多相关文章

Meeting Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5512 Description n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two…
http://acm.hdu.edu.cn/showproblem.php?pid=5512 gcd(a,b)的位置都是可以选的,之后判断一下奇偶 #include <iostream> #include <cstdio> using namespace std; int gcd(int a, int b) { ? b : gcd(b%a, a); } int main() { int T; scanf("%d", &T); ; cas <= T;…
Meeting Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1358    Accepted Submission(s): 435 Problem Description Bessie and her friend Elsie decide to have a meeting. However, after Farmer Jo…
Meeting Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3361    Accepted Submission(s): 1073 Problem Description Bessie and her friend Elsie decide to have a meeting. However, after Farmer Jo…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5512 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Descriptionn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mou…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5512 学习菊苣的博客,只粘链接,不粘题目描述了. 题目大意就是给了初始的集合{a, b},然后取集合里的两个元素进行加或者减的操作,生成新的元素.问最后最多能生成多少个元素.问答案的奇偶性. 首先一开始有a, b.那么如果生成了b-a(b>a),自然原来的数同样可以由b-a, a生成(b != 2a). 于是如此反复下去,最后的数必然是可以由两个数p, 2p生成的. 于是所有的数肯定可以表示成xp+…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5512 题意: 给定集合,最初有两个数a,b,如果两个人依次使用集合中的元素相加减,如果得到的数均不在在[1,n]中,则该人输,否则将新数放到集合中,游戏继续. 分析: 看8 6 8这组,发现只有偶数才能被取到,大胆猜能选的数都是最初的两个数的gcd,判断下选出的数的个数模2即可. 代码: #include<iostream> using namespace std; int gcd(int a,…
这是一题简单的博弈论!! 所有的空白+边界的数字(个数为n)为一堆,容易推出其SG函数值为n%2+1: 其他所有的数字(个数为m)的SG值为m%2. 再就是用dfs将空白部分搜一下即可!(注意细节) 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #inc…
看到这题时,当时还不会做,也没搞懂sg函数,于是狠狠的钻研了下博弈论,渐渐的知道了sg函数…… 现在在来做这题就很容易了,1A 打表容易发现在80左右的时候就出现循环节了 代码如下: #include<stdio.h> #include<cstring> #define in(x) scanf("%d",&x) ]; ]; int getsg(int x) { ) return sg[x]; memset(vis,,sizeof(vis)); ;i<…
http://acm.hdu.edu.cn/showproblem.php?pid=4312 题意:在上一题的基础上,由四个方向改为了八个方向. 思路: 引用自http://blog.csdn.net/bigbigship/article/details/43163719. 切比雪夫距离:设a(x1,y1),b(x2,y2);DIS = max(|x1-x2|,|y1-y2|) = (|x1-x2+y1-y2|+|x1-x2-y1+y2|)/2; 我们将点aa的坐标看成(x1+y1,x1-y1)…