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 ...
随机推荐
- 学习Github必须要会的知识
目的 托管项目代码 基本概念 仓库Respository 存放项目代码,每个项目对应一个仓库,多个开源项目则有多个仓库. 收藏Star 收藏项目,方便下次查看. 复制克隆项目Fork ...
- OGG实验:喂奶间隔数据表通过OGG配置同步
我之前在<使用SQL计算宝宝每次吃奶的时间间隔(数据保障篇)>中提到数据实时同步的方案,其中有一种是数据表通过OGG进行同步,当时没有详细展开测试,只给了之前学习OGG时的配置示例.由于之 ...
- 监听配置问题,SID与Service_Name区别
监听配置问题,SID与Service_Name区别 1.数据库实例名SID 概念:数据库实例名用于和操作系统进行联系的标识,是数据库和操作系统之间的交互用的书数据库实例名.实例名也被写入参数文件中,该 ...
- 反编译查看printf()的方法
源代码: package test2; public class ExplorationJDKSource { /** * @param args */ public static void main ...
- 7)给tab下面添加一个子非模态对话框
1)还是沿袭(6)那个代码 2)下面是步骤: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~·~~~~~~~~~~~~~~~~~~~~~~~~~~~ 然后,修改这个对 ...
- Java并发分析—ConcurrentHashMap
LZ在 https://www.cnblogs.com/xyzyj/p/6696545.html 中简单介绍了List和Map中的常用集合,唯独没有CurrentHashMap.原因是CurrentH ...
- HDU-2087 C - 剪花布条(KMP基本)
http://acm.hdu.edu.cn/showproblem.php?pid=2087 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能 ...
- 简单模拟B1001
#include<iostream> using namespace std; int main() { int n; ; cin >> n; ) { == ) { n = ( ...
- Log4Net 使用及组合公共类
好记性不如烂笔头,这次是由衷的感受到了! log4net 是一个很好用的日志记录工具,引用入项目中,如何查看项目内部运行情况,如何快速定位异常信息,好的日志记录能帮很大的忙: log4net 很好用, ...
- 微信获得access_token
<?php //获取access_token $appid = 'wx47a6fc3c1187e60d'; //测试账号appid $appsecret = '525f76d57c7bd7200 ...