Games
题目描述
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..
输入
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
输出
样例输入
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的更多相关文章
- Unity性能优化(3)-官方教程Optimizing garbage collection in Unity games翻译
本文是Unity官方教程,性能优化系列的第三篇<Optimizing garbage collection in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...
- Unity性能优化(4)-官方教程Optimizing graphics rendering in Unity games翻译
本文是Unity官方教程,性能优化系列的第四篇<Optimizing graphics rendering in Unity games>的翻译. 相关文章: Unity性能优化(1)-官 ...
- 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 ...
- (转) Playing FPS games with deep reinforcement learning
Playing FPS games with deep reinforcement learning 博文转自:https://blog.acolyer.org/2016/11/23/playing- ...
- Favorite Games
Samurai II: Vengeance: http://www.madfingergames.com/games
- 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 ...
- GDC2016 Epic Games【Bullet Train】 新风格的VR-FPS的制作方法
追求“舒适”和“快感”的VR游戏设计方法 http://game.watch.impress.co.jp/docs/news/20160318_749016.html [Bullet Tr ...
- 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 ...
- 读书笔记2014第6本:《The Hunger Games》
以前从未读过一本完整的英文小说,所有就在今年的读书目标中增加了一本英文小说,但在头四个月内一直没有下定决定读哪一本.一次偶然从SUN的QQ空间中看到Mockingjay,说是不错的英文小说,好像已经是 ...
- [codeforces 325]B. Stadium and Games
[codeforces 325]B. Stadium and Games 试题描述 Daniel is organizing a football tournament. He has come up ...
随机推荐
- JS-表单非空验证
JavaScript 表单验证 JavaScript 可用来在数据被送往服务器前对 HTML 表单中的这些输入数据进行验证. 实例:1.用户名的非空验证代码如下: <head> <m ...
- 学习Github必须要会的知识
目的 托管项目代码 基本概念 仓库Respository 存放项目代码,每个项目对应一个仓库,多个开源项目则有多个仓库. 收藏Star 收藏项目,方便下次查看. 复制克隆项目Fork ...
- 2.3 使用Android Studio 简单设计UI界面
首先 创建一个新的项目找到app 文件目录下的layout的 activity_main.xml 因为Android Studio 是可视化的,所有操作都可以在图形界面进行. 该res 界面当中 d ...
- 聚类算法总结以及python代码实现
一.聚类(无监督)的目标 使同一类对象的相似度尽可能地大:不同类对象之间的相似度尽可能地小. 二.层次聚类 层次聚类算法实际上分为两类:自上而下或自下而上.自下而上的算法在一开始就将每个数据点视为一个 ...
- shell中通过sed替换文件中路径
通常sed指令修改行内容时使用:sed -i " 9 s/^.*/"type in what you want modified!"/" 其中"typ ...
- HashMap源码分析(一)
基于JDK1.7 HashMap源码分析 概述 HashMap是存放键值对的集合,数据结构如下: table被称为桶,大小(capacity)始终为2的幂,当发生扩容时,map容量扩大为两倍 Hash ...
- uploadify ASP.net 使用笔记
<script type="text/javascript" src="jquery.uploadify.min.js"></script & ...
- mysql my.ini 性能调优
MYSQL服务器my.cnf配置文档详解 硬件:内存16G [client] port = 3306 socket = /data/3306/mysql.sock [mysql] no-auto-re ...
- Juniper srx新增接口IP,使PC直连srx(转)
转自:https://www.jianshu.com/p/bc27134bde3d Juniper srx新增接口IP,使PC直连srx 2018.11.19 14:24:15字数 424 概述 需求 ...
- HTTP、MQTT、WebSocket有什么区别
https://blog.csdn.net/linyunping/article/details/81950185 相同点:均为OSI 7层模型(应用层.表示层.会话层.传输层.网络层.数据链路层.物 ...