取石子(八)
时间限制:1000 ms | 内存限制:65535 KB
难度:3
描述
有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者。...
分类:
其他好文 时间:
2014-09-21 10:35:30
阅读次数:
221
题目:
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i...
分类:
其他好文 时间:
2014-09-21 03:10:29
阅读次数:
265
题目:1002 A Corrupt Mayor's Performance Art
题意:有一个长度 n 的序列,初始染色2,有两种操作,P x ,y ,z,区间x---y染色为z,另一种Q x,y,查询区间 x -- y 有几种颜色,并输出,注意会覆盖。
分析:跟POJ 2777一样,不过这个要输出颜色,所以线段树查询的时候顺便把路径存起来打印。代码:
AC代码:
#...
分类:
其他好文 时间:
2014-09-20 20:07:29
阅读次数:
333
原理讲的清晰:Manacher's ALGORITHM: O(n)时间求字符串的最长回文子串注意:①动态生命P[]和newStr数组后,不要忘记delete[] //其实这是基本的编码习惯②最终返回结果是P[i]-1下面是自己写的Manacher函数int manacher(char *src){ ...
分类:
其他好文 时间:
2014-09-20 19:44:09
阅读次数:
213
[leetcode]Search Insert Position...
分类:
其他好文 时间:
2014-09-20 14:08:47
阅读次数:
160
Revenge of GCD
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768
K (Java/Others)
...
分类:
其他好文 时间:
2014-09-20 14:08:17
阅读次数:
155
Revenge of Fibonacci
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 372 Accepted Submission(s): 177
Problem Description
In math...
分类:
其他好文 时间:
2014-09-20 10:03:57
阅读次数:
156
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5018
思路:直接计算判断就是啦,注意一点要判断给出的A,B。。。。
code
#include
#include
#include
#include
#include
using namespace std;
int main()
{
int F[1000];
int...
分类:
其他好文 时间:
2014-09-19 22:33:46
阅读次数:
267
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019
题目大意:给出A,B两个数,求第k大的公约数,如果没有输出-1
思路:直接把A,B的公约数全部求出来,然后找出来就行啦,当时没有注意数据大小居然是10^12,用的int ,所以果断错啦,赛完才发现,坑呀。。。。。
注意要用long long或是__int64。。。。。
code:
#i...
分类:
其他好文 时间:
2014-09-19 22:32:24
阅读次数:
215