UVA 11892 - ENimEN
题目链接
题意:给定n堆石头,两人轮流取,每次只能取1堆的1到多个,如果上一个人取了一堆没取完,那么下一个人必须继续取这堆,取到最后一个石头的赢,问谁赢
思路:简单推理一下,后手只可能在堆数偶数并且都是1的情况下才可能赢
代码:
#include
#include
const int N = 20005;
int t, n,...
分类:
其他好文 时间:
2014-07-18 22:35:48
阅读次数:
197
Description
You have just finished a compiler design homework question where you had to find the parse tree of an expression. Unfortunately you left your assignment in the library, but lucki...
分类:
其他好文 时间:
2014-07-18 22:19:15
阅读次数:
249
题目如下:
The Sultan's Successors
The Sultan of Nubia has no children, so she has decided that thecountry will be split into up to
k separate parts on her death andeach part wi...
分类:
其他好文 时间:
2014-07-18 22:00:59
阅读次数:
310
UVA 11927 - Games Are Important
题目链接
题意:给定一个有向图,结点上有一些石头,两人轮流移动石头,看最后谁不能移动就输了,问先手还后手赢
思路:求出每个结点的sg函数,然后偶数个石头结点可以不用考虑,因为对于偶数情况,总步数肯定能保证是偶数,所以只要考虑奇数情况的结点
代码:
#include
#include
#include ...
分类:
其他好文 时间:
2014-07-18 21:32:27
阅读次数:
224
UVA 12293 - Box Game
题目链接
题意:两个盒子,一开始一个盒子有n个球,一个只有1个球,每次把球少的盒子中球消掉,把多的拿一些球给这个盒子,最后不能操作的输(球不能少于1个),Alice先手,问谁赢
思路:博弈,题目其实可以转化为,给定一个n,每次把减少1到n/2的数字,最后谁是1谁就输了,那么可以去递推前几项找个规律,或者推理,都可以发现只要是2^i - 1...
分类:
其他好文 时间:
2014-07-18 21:27:44
阅读次数:
186
uva548:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=489题意:给出一颗二叉树的中序遍历和后序遍历,求一条路径,这条路径从根...
分类:
其他好文 时间:
2014-07-18 20:21:14
阅读次数:
205
In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decided on the following strategy. Every ...
分类:
其他好文 时间:
2014-07-18 20:15:42
阅读次数:
234
Problem H
Morning Walk
Time Limit
3 Seconds
Kamalis a Motashotaguy. He has got a new job in Chittagong. So, he has moved to Chittagong fromDinajpur. He was getting fatter i...
分类:
其他好文 时间:
2014-07-18 17:01:16
阅读次数:
219
UVA 11762 - Race to 1
题意:给定一个n,每次随即选择一个n以内的质数,如果不是质因子,就保持不变,如果是的话,就把n除掉该因子,问n变成1的次数的期望值
思路:tot为总的质数,cnt为质因子个数,那么f(n)=(1?cnt/tot)?f(n)+∑f(n/prime)?(1/tot),然后利用记忆化搜索去做即可
代码:
#include
#inclu...
分类:
其他好文 时间:
2014-07-17 15:36:46
阅读次数:
211
Where is the Marble? Where is the Marble?Raju and Meena love to play with Marbles. They have got a lot of marbles with numbers written on them. At the...
分类:
其他好文 时间:
2014-07-17 14:20:27
阅读次数:
376