/* 题意:Nim游戏! 思路:通过异或,判断将n个数表示成二进制的形式之后,是否对应位的数字1 的个数是偶数! */ #includeusing namespace std;int main(){ int n, x, s; while(cin>>n){ s=...
分类:
其他好文 时间:
2014-09-16 21:46:11
阅读次数:
219
一、对于引用类型你了解多少? string a = "1"; string b = a; a = "2"; print(b); GameObject a = new GameObject("1");//game object 有一个 name 构造 GameObjec...
分类:
其他好文 时间:
2014-09-16 20:21:20
阅读次数:
179
题目地址:HDU 1517
NP状态转换。
可以把题目的向上乘变成向下除。这样1是终结状态,设1的时候为必败点。
根据所有能一步到达必败点的点是必胜点,所以[x,x*9]必胜点;根据只能到达必胜点的点是必败点,所以[x*9+1,x*9*2]是必败点.
然后求解。
代码如下:
#include
#include
#include
#include
#include
#inclu...
分类:
其他好文 时间:
2014-09-16 14:17:00
阅读次数:
111
最大子矩阵,(City Game)SEERC 2004,LA 3029
白书上的例题,看了两节课,终于理解了。DP的思想。
扫描的时候维护 up朝上能有多少空格,left 最多朝左走到多少,right 朝右走到多少。
所以只需要扫描一遍即可得出答案 = up*(right-left+1)
我定义left数组的时候跟 iostream 冲突了。
#inclu...
分类:
其他好文 时间:
2014-09-16 12:45:10
阅读次数:
150
A New Stone GameTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 4177Accepted: 2227DescriptionAlice and Bob decide to play a new stone game.At...
分类:
其他好文 时间:
2014-09-16 02:41:29
阅读次数:
280
第一种思路是:
dp(i):到位置i所需要的最少步数
dp(i)一定是递增的,所以从j=A[i]开始(从最远的位置开始),更新数组直到dp(j+i)
如果去掉,会TLE
int jump(int A[], int n) {
int* dp = new int[n];//dp[i]到i所需的最小步数
memset(dp, 0x3f, sizeof(int)...
分类:
其他好文 时间:
2014-09-16 01:38:29
阅读次数:
241
HDU 1846 Brave Game (巴什博弈)Description十年前读大学的时候,中国每年都要从国外引进一些电影大片,其中有一部电影就叫《勇敢者的游戏》(英文名称:Zathura),一直到现在,我依然对于电影中的部分电脑特技印象深刻。 今天,大家选择上机考试,就是一种勇敢(brave)的...
分类:
其他好文 时间:
2014-09-15 22:47:29
阅读次数:
330
题目地址:POJ 2484
很简单的智力题。。。当n>4时候,后手方完全可以根据剩下的奇偶情况使得剩下了偶数个并且对称,然后每当先手出一次,后手就可以模仿着先手在对称的地方出一次,这样的话,后方是必胜的。
代码如下:
#include
#include
#include
#include
#include
#include
#include
#include
#include...
分类:
其他好文 时间:
2014-09-15 21:25:49
阅读次数:
273
# include
# include
# include
# include
# include
using namespace std;
int main()
{
int n,m,i,a,b,cot;
while(~scanf("%d%d",&n,&m))
{
cot=0;
for(i=0; i<n; i++)
...
分类:
其他好文 时间:
2014-09-15 21:22:29
阅读次数:
268
Problem Description
Here is a game for two players. The rule of the game is described below:
● In the beginning of the game, there are a lot of piles of beads.
● Players take turns to play. ...
分类:
其他好文 时间:
2014-09-15 21:21:29
阅读次数:
202