Games

题目描述

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]。
取哪一个数就再异或就好了
暴力转移就好
 1 #include <iostream>
 2 #include <bits/stdc++.h>
 3 #define maxn 1005
 4 using namespace std;
 5 typedef long long ll;
 6 const ll mod=1e9+7;
 7 int dp[maxn][12][2*maxn]={0};//前i个选j个,异或为k。
 8 //dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k^a[i]];
 9 int main()
10 {
11     ll n,t,d,i,j,k;
12     scanf("%lld",&t);
13     ll a[maxn]={0};
14     while(t--)
15     {
16         scanf("%lld%lld",&n,&d);
17         memset(dp,0,sizeof(dp));
18         ll maxim=-1;
19         for(i=1;i<=n;i++)
20         {
21             scanf("%d",&a[i]);
22             maxim=max(maxim,a[i]);
23         }
24         ll sum=a[1];
25         for(i=2;i<=n;i++)
26         {
27             sum=sum^a[i];
28         }
29         for(i=1;i<=n;i++)
30         {
31             dp[i][0][0]=1;
32         }
33        for(i=1;i<=n;i++)
34        {
35            for(j=1;j<=d&&j<=i;j++)
36            {
37                for(k=0;k<=2*maxim;k++)
38                {    if(i==1) dp[i][j][a[i]]=1;
39                    else dp[i][j][k]=(dp[i-1][j][k]+dp[i-1][j-1][k^a[i]])%mod;
40                }
41            }
42        }
43        ll ans=0;
44        for(i=0;i<=d;i++)
45        {
46            ans=(ans+dp[n][i][sum])%mod;
47        }
48        printf("%lld\n",ans);
49     }
50     return 0;
51 }
View Code

dp还不怎么会 嘤

转载于:https://www.cnblogs.com/smallocean/p/9041227.html

标题基于Python的自主学习系统后端设计与实现AI更换标题第1章引言介绍自主学习系统的研究背景、意义、现状以及本文的研究方法和创新点。1.1研究背景与意义阐述自主学习系统在教育技术领域的重要性和应用价值。1.2国内外研究现状分析国内外在自主学习系统后端技术方面的研究进展。1.3研究方法与创新点概述本文采用Python技术栈的设计方法和系统创新点。第2章相关理论与技术总结自主学习系统后端开发的相关理论和技术基础。2.1自主学习系统理论阐述自主学习系统的定义、特征和理论基础。2.2Python后端技术栈介绍DjangoFlask等Python后端框架及其适用场景。2.3数据库技术讨论关系型和非关系型数据库在系统中的应用方案。第3章系统设计与实现详细介绍自主学习系统后端的设计方案和实现过程。3.1系统架构设计提出基于微服务的系统架构设计方案。3.2核心模块设计详细说明用户管理、学习资源管理、进度跟踪等核心模块设计。3.3关键技术实现阐述个性化推荐算法、学习行为分析等关键技术的实现。第4章系统测试与评估对系统进行功能测试和性能评估。4.1测试环境与方法介绍测试环境配置和采用的测试方法。4.2功能测试结果展示各功能模块的测试结果和问题修复情况。4.3性能评估分析分析系统在高并发等场景下的性能表现。第5章结论与展望总结研究成果并提出未来改进方向。5.1研究结论概括系统设计的主要成果和技术创新。5.2未来展望指出系统局限性并提出后续优化方向。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值