题目描述

Alice and Bob are playing a stone game. There are n piles of stones. In each turn, a player can remove some stones from a pile (the number must be positive and not greater than the number of remaining stones in the pile). One player wins if he or she remove the last stone and all piles are empty. Alice plays first.
To make this game even more interesting, they add a new rule: Bob can choose some piles and remove entire of them before the game starts. The number of removed piles is a nonnegative integer, and not greater than a given number d. Note d can be greater than n, and in that case you can remove all of the piles.
Let ans denote the different ways of removing piles such that Bob are able to win the game if both of the players play optimally. Bob wants you to calculate the remainder of ans divided by 10^9+7..

输入

The first line contains an integer T, representing the number of test cases.
For each test cases, the first line are two integers n and d, which are described above.
The second line are n positive integers ai, representing the number of stones in each pile.
T ≤ 5, n ≤ 10^3, d ≤ 10, ai ≤ 10^3

 

输出

For each test case, output one integer (modulo 10^9 + 7) in a single line, representing the number of different ways of removing piles that Bob can ensure his victory.

样例输入

2
5 2
1 1 2 3 4
6 3
1 2 4 7 1 2

样例输出

2
5
尼姆博弈:定理:(a1,a2,...,aN)为奇异局势当且仅当a1^a2^...^aN=0    
比赛的时候只知道是博弈,让剩下的异或和为0
这个主要还是DP
dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k^a[i]]; 表示前i个,取j,异或为k。 则可由第i个不取,异或为k,第i个取,则 设x^a[i]=k ,x=k^a[i]。
取哪一个数就再异或就好了
暴力转移就好
 #include <iostream>
#include <bits/stdc++.h>
#define maxn 1005
using namespace std;
typedef long long ll;
const ll mod=1e9+;
int dp[maxn][][*maxn]={};//前i个选j个,异或为k。
//dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k^a[i]];
int main()
{
ll n,t,d,i,j,k;
scanf("%lld",&t);
ll a[maxn]={};
while(t--)
{
scanf("%lld%lld",&n,&d);
memset(dp,,sizeof(dp));
ll maxim=-;
for(i=;i<=n;i++)
{
scanf("%d",&a[i]);
maxim=max(maxim,a[i]);
}
ll sum=a[];
for(i=;i<=n;i++)
{
sum=sum^a[i];
}
for(i=;i<=n;i++)
{
dp[i][][]=;
}
for(i=;i<=n;i++)
{
for(j=;j<=d&&j<=i;j++)
{
for(k=;k<=*maxim;k++)
{ if(i==) dp[i][j][a[i]]=;
else dp[i][j][k]=(dp[i-][j][k]+dp[i-][j-][k^a[i]])%mod;
}
}
}
ll ans=;
for(i=;i<=d;i++)
{
ans=(ans+dp[n][i][sum])%mod;
}
printf("%lld\n",ans);
}
return ;
}

dp还不怎么会 嘤

Games的更多相关文章

  1. Unity性能优化(3)-官方教程Optimizing garbage collection in Unity games翻译

    本文是Unity官方教程,性能优化系列的第三篇<Optimizing garbage collection in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...

  2. Unity性能优化(4)-官方教程Optimizing graphics rendering in Unity games翻译

    本文是Unity官方教程,性能优化系列的第四篇<Optimizing graphics rendering in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...

  3. Learning in Two-Player Matrix Games

    3.2 Nash Equilibria in Two-Player Matrix Games For a two-player matrix game, we can set up a matrix ...

  4. (转) Playing FPS games with deep reinforcement learning

    Playing FPS games with deep reinforcement learning 博文转自:https://blog.acolyer.org/2016/11/23/playing- ...

  5. Favorite Games

    Samurai II: Vengeance: http://www.madfingergames.com/games

  6. CF456D A Lot of Games (字典树+DP)

    D - A Lot of Games CF#260 Div2 D题 CF#260 Div1 B题 Codeforces Round #260 CF455B D. A Lot of Games time ...

  7. GDC2016 Epic Games【Bullet Train】 新风格的VR-FPS的制作方法

    追求“舒适”和“快感”的VR游戏设计方法   http://game.watch.impress.co.jp/docs/news/20160318_749016.html     [Bullet Tr ...

  8. Supercell only provide the best games for players

    Supercell only provide the best games for players Supercell start to change all, Supercell's first t ...

  9. 读书笔记2014第6本:《The Hunger Games》

    以前从未读过一本完整的英文小说,所有就在今年的读书目标中增加了一本英文小说,但在头四个月内一直没有下定决定读哪一本.一次偶然从SUN的QQ空间中看到Mockingjay,说是不错的英文小说,好像已经是 ...

  10. [codeforces 325]B. Stadium and Games

    [codeforces 325]B. Stadium and Games 试题描述 Daniel is organizing a football tournament. He has come up ...

随机推荐

  1. Win10下 Java环境变量配置

    安装java的JDK   下载地址 此电脑->属性->高级设置 "系统变量"新建   变量名:Java_Home   变量值:D:\Program Files\Java ...

  2. Python中的常用内置对象之map对象

    如果你了解云计算的最重要的计算框架Mapreduce,你就对Python提供的map和reduce对象有很好的理解,在大数据面前,单机计算愈加力不从心,分布式计算也就是后来的云计算的框架担当大任,它提 ...

  3. transform—3D立方体

    1.思路分析 第一步:首先需要一个大盒子,承载立方体的六个面: 第二步:立方体的六个面需要3D转化在特定的位置,拼接成一个立方体: 第三步:设置动画: 2.代码实现 第一步:创建div并且设置样式: ...

  4. Hdu_3068 Manacger算法的心得

    关于manacher算法,似乎在学完KMP之后,比较容易上手,虽然有些原理方面,我没有理解的太深. Manacher就是解决回文串的问题,求一个字符串中的最长回文子串. Manacher算法首先对字符 ...

  5. 京东云携手Mellanox,设计最先进SDN硬件加速功能并开源

    京东云携手Mellanox,设计最先进SDN硬件加速功能并开源 最新技术播报 京东云开发者社区  导语新一代 SDN.NFV 和云原生计算技术正在推动应用实例的极限,这些实例可以在虚拟化和容器化的服务 ...

  6. mysql自关联和多表连接查询

    自关联操作         多表连接查询  inner  join 内查询   left  join  左查询   right  join  右查询                          ...

  7. 2019年阿里java面试题

    一.JVM与性能优化 描述一下 JVM 加载 Class 文件的原理机制? 什么是类加载器? 类加载器有哪些? 什么是tomcat类加载机制? 类加载器双亲委派模型机制? Java 内存分配? Jav ...

  8. Ubuntu编译protobuf

    个人博客地址:http://www.bearoom.xyz/2019/08/24/ubunt-protobuf/ 因为编译了tensorflow C++的版本,然后提示protobuf的版本不对应引起 ...

  9. Linux 基本操作学习

    Linux 学习 虚拟机 (Virtual Machine) 指通过软件模拟的具有完整硬件系统功能的,运行再一个完全隔离环境中的完整计算机系统 常用 Linux 命令 命令 对应英文 作用 ls li ...

  10. Exchange 2016 CU3 安装失败解决方法

    Exchange 2016 CU3 安装失败解决方法 1. 问题: 由于前期安装过Exchange 2010 ,服务器非正常删除,后期人员无法跟进,在新安装Exchange 2016时准备工作正常完成 ...