本题涉及博弈论中的Nim游戏博弈. Nim游戏博弈详解链接: http://www.cnblogs.com/exponent/articles/2141477.html 本题解题报告详解链接: http://blog.csdn.net/woshi250hua/article/details/7824609 我的代码,写的较挫,4000多ms,压着时间过,时间限制是5s.我预处理了所有1-5*10^6的数的素因子个数,用的是dp 的思想,先预处理1-5*10^6的数的最小素因子,存在a数组中,然后…
ZOJ 3529 - A Game Between Alice and Bob Time Limit:5000MS     Memory Limit:262144KB     64bit IO Format:%lld & %llu Description Alice and Bob play the following game. A series of numbers is written on the blackboard. Alice and Bob take turns choosing…
A Game Between Alice and Bob Time Limit: 5 Seconds      Memory Limit: 262144 KB Alice and Bob play the following game. A series of numbers is written on the blackboard. Alice and Bob take turns choosing one of the numbers, and replace it with one of…
思路:每个数的SG值就是其质因子个数,在进行nim博弈 代码如下: #include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<set> #include<vector> #define ll long long #define M 5000005 #define inf 1e10 #d…
Alice and Bob Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KB Total submit users: 20, Accepted users: 10 Problem 11499 : No special judgement Problem description Alice and Bob are interested in playing games. One day, they invent…
Foj 2296 Alice and Bob 题意 两个人博弈,规则如下:轮流取0~9中的数字,最后Alice所得的数字个数为1~n中,数位在Alice所取集合中出现奇数次的. 双方想获得尽量多,问Alice能获得几个. 题解 观察一下,如果n是十的倍数,最后肯定是一人一半,这样一来,状态数应该会减少很多,我们就可以直接去搜. 半个月前我补这道题,一直觉得是个dp问题,现在想想,其实就是暴力去做极大极小过程,只是需要把状态数表示出来. 因为有了一开始的观察,所以可以把数字分成四类,再记一下前几位…
题意: 一个无限大的棋盘,一开始在1,1,有三种移动方式,(x+1,y)(x,y+1) (x+k,y+k)最后走到nm不能走了的人算输.. 析:.我们看成一开始在(n,m),往1,1,走,所以自然可以从1,1,开始递推往出,那么打表程序就出来了.. 打出表以后我们观察到k等于1时稍有特殊,其他则与  (min(cx,cy)&1)^((n+m)&1)) 有关ps(其中cx=n/(k+1),cy=m/(k+1)) 那么就愉快的分类讨论外加试一试和表对照一下就好了.. 代码如下: #includ…
题目大意: 有K堆石子,每堆有Ki个.两人的操作能够是:             1 从某一堆拿走一个 假设该堆在此之后没有石子了.就消失             2 合并两个堆        求是否先手必胜,先手胜输出Alice.否则输出Bob 思路: 这道题读完后毫无头绪.推了半天也推不个所以然来,參看大神代码后,感觉就是一个记忆化搜索啊,唉,知识学多了不会用还是白搭.还得多做题啊! 这里我们把数字分成 1,2,大于等于3的奇数,大于等于4的偶数四类.        这样分的原因在于.一个大…
题目链接 题意 : 玩台球.Alice 和 Bob,一共可以进行m次,Alice 先打.有一个白球和n个标有不同标号的球,称目标球为当前在桌子上的除了白球以外的数值最小的球,默认白球的标号为0.如果白球落入洞中,要把白球拿出来放在桌子上,如果是其他的球就不拿哪怕是犯规打进去的.每打一局(每一局代表每人打一杆)时当发生以下三种行为时算是犯规,会将相应的罚分加给对方,自己不减分. 白球没有打中任何球.将目标球的数值加到对方的分数上. 白球没有入洞且至少打中一个球,一开始没有打中目标球或者一开始同时打…
原题: ZOJ 3666 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3666 博弈问题. 题意:给你1~N个位置,N是最终点,1~N-1中某些格子能够移石头到另外一些指定的格子,1~N-1上有M个石头,位置不定,现在Alice和Bob要把这些石头全部移到N点,谁不能移则输,问先手必胜还是后手必胜. 做法:求出每个位置的SG函数值,然后将放石头的M个位置的SG函数值做异或,异或为0则Alice赢.这里讲坐标反转,1~N…
Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 147    Accepted Submission(s): 22 Problem Description As you know, Alice and Bob always play game together, and today they get a…
Description Alice和Bob在玩游戏.有n个节点,m条边(0<=m<=n-1),构成若干棵有根树,每棵树的根节点是该连通块内编号最 小的点.Alice和Bob轮流操作,每回合选择一个没有被删除的节点x,将x及其所有祖先全部删除,不能操作的人输 .注:树的形态是在一开始就确定好的,删除节点不会影响剩余节点父亲和儿子的关系.比如:1-3-2 这样一条链 ,1号点是根节点,删除1号点之后,3号点还是2号点的父节点.问有没有先手必胜策略.n约为10w. 显然只要算出每颗子树的sg值就可以…
Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynomial like this: (a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1). Then Alice as…
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2608 Alice and Bob Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynomial li…
Alice and Bob Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 5   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Alice and Bob's game nev…
Alice and Bob Time Limit:3000MS     Memory Limit:128000KB     64bit IO Format:%lld & %llu Submit Status Practice ACdream 1112 Description Here  is Alice and Bob again ! Alice and Bob are playing a game. There are several numbers. First, Alice choose…
题目传送门 /* 题意: 求(a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1) 式子中,x的p次方的系数 二进制位运算:p = 2 ^ i + 2 ^ j + 2 ^ k + ...,在二进制表示下就是1的出现 例如:10 的二进制 为1010,10 = 2^3 + 2^1 = 8 + 2,而且每一个二进制数都有相关的a[i],对p移位运算,累计取模就行了 */ #include <cstdio> #include…
Alice and Bob Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynomial like this: (a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1). T…
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3716 Accepted Submission(s): 1179 Problem Description Alice and Bob's game never ends. Today, they introduce a new game. In this game…
我之前做过一些博弈的题目,以为博弈都是DP,结果被坑了很多次,其实博弈有很多种,在此,把我见过的类型都搬上来. 1,HDU3951(找规律) 题意:把n枚硬币围成一个圆,让Alice和Bob两个人分别每人每次拿k(1<=k<=m)枚连续的硬币,谁能拿到最后谁赢: 思路:找规律,A拿了之后,B只要把剩下的分成偶数块,B就能赢,找到的规律就是除了m=1 && n&1是A赢,其余全是B赢,即B能够分成偶数块: #include <cstdio> #include…
题目链接:1484 - Alice and Bob's Trip 题意:BOB和ALICE这对狗男女在一颗树上走,BOB先走,BOB要尽量使得总路径权和大,ALICE要小,可是有个条件,就是路径权值总和必须在[L,R]之间,求终于这条路径的权值. 思路:树形dp,dp[u]表示在u结点的权值,往下dfs的时候顺带记录下到根节点的权值总和,然后假设dp[v] + w + sum 在[l,r]内,就是能够的,状态转移方程为 dp[u] = max{dp[v] + w }(bob) dp[u] = m…
Problem Description Alice and Bob's game never ends. Today, they introduce a new game. In this game, both of them have N different rectangular cards respectively. Alice wants to use his cards to cover Bob's. The card A can cover the card B if the hei…
  Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynomial like this: (a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1). Then Alice…
题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynomial like this: (a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1). Then Alice ask Bob Q questions. In the expansion of the Polynomial, G…
Alice and Bob Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1130 Accepted Submission(s): 407 Problem Description Alice and Bob are very smart guys and they like to play all kinds of games in the…
Problem Description The famous "Alice and Bob" are playing a game again. So now comes the new problem which need a person smart as you to decide the winner. The problem is as follows: They are playing on a rectangle paper, Alice and Bob take tur…
Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4174    Accepted Submission(s): 1310 Problem Description Alice and Bob's game never ends. Today, they introduce a new game. In thi…
题意:http://acdream.info/problem?pid=1112 Problem Description Here  is Alice and Bob again ! Alice and Bob are playing a game. There are several numbers.First, Alice choose a number n.Then he can replace n (n > 1)with one of its positive factor but not…
Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2901    Accepted Submission(s): 941 Problem Description Alice and Bob's game never ends. Today, they introduce a new game. In this…
option=com_onlinejudge&Itemid=8&page=show_problem&problem=4246" target="_blank" style="">题目连接:uva 1500 - Alice and Bob 题目大意:在黑板上又一个序列,每次操作能够选择一个数减1,或者是合并两个数,一个数被减至1则自己主动消除,不能操作者输. 解题思路:结论,对于大于1的数能够看成是一个整数s,为消除他们的总操作…