题目描述

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. 18 12 26 css 学习 选择器

    1.标签选择器 标签选择器,此种选择器影响范围大,建议尽量应用在层级选择器中.举例: *{margin:0;padding:0} div{color:red} <div>....</ ...

  2. clion 的 安装 变量配置的 搬运工(有点基础应该能看 大家看不懂 就是我自己看 哈哈哈哈哈哈)

    1  自行安装一个  clion 2 https://blog.csdn.net/u013023297/article/details/80723847   mingw  的配置    第二篇好像当时 ...

  3. MySQL 存储引擎(MyISAM、InnoDB、NDBCluster)

    前言 MySQL 的存储引擎可能是所有关系型数据库产品中最具有特色的了,不仅可以同时使用多种存储引擎,而且每种存储引擎和MySQL之间使用插件方式这种非常松的耦合关系. 由于各存储引擎功能特性差异较大 ...

  4. (转载)Tomcat 报错 (The tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config is mi)

    错误如图所示: 目前对于这个错误的原因尚不清楚,目前只知道如何解决这个错误,等到以后知道了原因之后再更改此文. 原因猜测: 之前你的eclipse关联的tomcat由于某种原因出现了信息丢失,需要重新 ...

  5. webpack4+vue 打包 就是没效果?求解!!!

    开始对着视频操作 教学视频 用的webpack2 所以没成功  但是 Jquery 可以 成功渲染.Vue就不行. 百度 webpack4+vue打包简单入门:https://segmentfault ...

  6. 静态页面缓存(thymeleaf模板writer)

    //前端html <!DOCTYPE html><html lang="en"> <head> <meta charset="U ...

  7. Asp.Net MVC主项目访问不到分离项目控制器的解决方案

    我在portal主项目外新建一个分离项目,控制器和Model都写在分离项目中,视图层写在portal中. 我更改了命名空间,引用了Dll,还是不能访问到控制器. 找到问题: 最后我发现是主项目port ...

  8. Python3 Windows服务器简单实现 手机访问

    设备 1. PC with Win10 2. Python 3.5.1 步骤 打开CMD,cd 到e盘,mkdir pythonWebserver 建立文件夹 //在E盘建立文件夹,作为服务器的根目录 ...

  9. eclipse Java EE 与 Java 区别

    1. 综述 eclipse IDE 一般来说有三种可切换的模式 Java EE Java 调试 可直接下拉至底部看两者的比较. 2. Java Java 是带有用户界面的 基本IDE ,缺少数据库和w ...

  10. iPhoneX的后遗症要持续多久?

    iPhone X的推出算得上苹果历史上的大事件,这款梳着刘海头型的手机作为iPhone十周年纪念款手机,承载着苹果和整个产业链巨大的希望,正因如此,包括苹果在内的大量企业,把宝都压到了这款手机上.后来 ...