dp --- acdream原创群赛(16) --- B - Apple

<传送门>

 

 

B - Apple#

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
SubmitStatus

Problem Description#

Alice and Bob are coming.
This time, they are playing with apples. Initially, there are N baskets and M apples. Both baskets and apples are distinguishable. Each turn, (s)he can choose adding a basket or an apple. Alice always plays first. When (s)he complete operation, if the number of ways to split apples into baskets is not less than A, (s)he lose.
Now Alice wonder whether she can win if both player use best strategy.

Input#

There are multiple test cases.
Each test case contains three integers N, M and A.
1 <= N <= 10,000
1 <= M <= 30
2 <= A <= 1,000,000,000

Output#

For each test case, if Alice can win, output "win" and if Bob can win, output "lose"; otherwise output "draw".

Sample Input#

3 1 4
2 2 10

Sample Output#

lose
win

 

 【题目大意】

有N个篮子和M个苹果,篮子和苹果都是有区别的。
对于每一个回合,他或她可以选择增加一个篮子或者一个苹果。爱丽丝总是第一个动手。
当他们完成一次操作后,如果将苹果分配到篮子里的方法大于等于A,则输。

现在要你判断先手的胜负。

N----篮子数
M---苹果数
A---上限

 

【题目分析】

定位:常见的dp博弈 、记忆化搜索

像这种没有SG函数的博弈已经很少见了,SG函数的博弈才真叫人蛋疼。

这题的一个细节的地方就是当篮子数=1的时候判断有点麻烦,其他的也不是很难。

具体看代码(注释很详细):

  

 

posted @   北岛知寒  阅读(416)  评论(2编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示
主题色彩