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 ...
随机推荐
- linux 安装禅道 和 CentOS 7 开放防火墙端口 命令
linux 安装禅道链接: https://www.cnblogs.com/maohuidong/p/9750202.html CentOS 7 开放防火墙端口 命令 链接:https://www. ...
- 腾讯大佬告诉你,写Python到底用什么IDE合适
不管你是 Python 新手还是老鸟,肯定纠结过一个问题: 到底用什么编辑器写 Python 代码好? 为此,我们调查了数十位鹅厂程序猿们爱用的 Python IDE,从他们对每款编辑器的看法中,也许 ...
- idea拉取git项目并创建为maven项目(新创建github项目)
0 环境 系统环境:win10 编辑器:idea 1 正文 1 clone项目 跟着提示yes 下一步 2 在根节点添加pom.xml(maven) <?xml version="1. ...
- 吴裕雄--天生自然 JAVASCRIPT开发学习:函数调用
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- count(1),count(*)和count(列)的比较
转自:https://www.cnblogs.com/Caucasian/p/7041061.html 1.关于count(1),count(*),和count(列名)的区别 相信大家总是在工作中,或 ...
- 转载:Apache优化:修改最大并发连接数
本文转自:https://blog.csdn.net/bjash/article/details/50394894 Apache是一个跨平台的web服务器,由于其简单.稳定安全的特性,被广泛应用于计算 ...
- CodeForces-1100C NN and the Optical Illusion 简单数学
题目链接:https://vjudge.net/problem/CodeForces-1100C 题意: 题目给出外部圆的数目n和内部圆的半径r,要求求出外部圆的半径以满足图片要求. 显然这是一道数学 ...
- Android studio个人常用快捷键
个人常用重点: 电脑模式不一样需要加上fn键进行切换 Alt+回车/Enter 导入包,实现接口的方法.自动修正 Ctrl+X 删除行 Ctrl+D 复制行 Ctrl+Shift+Space 自动补 ...
- python中selenium自动化常用关键字
一:定位八种方法 例如: 二:常见的webdriver方法 1.浏览器相关:(打开浏览器先导入webdriver模块) (1)set_window_size(480,800)调整浏览器宽高大小 (2) ...
- Evaluation metrics for classification
Accuracy/Error rate ACC = (TP+TN)/(P+N) ERR = (FP+FN)/(P+N) = 1-ACC Confusion matrix Precision/Recal ...