策略题

There are four kinds of cards, respectively, 1,2, 3,4 numbers. There are seven cards for each type of card. At this point, there are two players, and two players take one card in turn. When the sum of the cards is equal to 27, the next player wins. Which strategy can be used to ensure that the player wins?

假设两个玩家分别是A,B。此时来倒推。

A+B 剩余 先拿先赢或者输 做法
26 1  A+B=26,此时只能拿1,输
25 2  拿1剩1,剩1输
24 3  拿2剩1,剩1输
23 4  拿3剩1,剩1输
22 5  拿4剩1,剩1输
 拿1剩5,剩5时先拿先赢(此时剩5拿4赢),拿1输;拿2剩4,剩4时先拿先赢(此时剩4拿3赢),拿2输;拿3剩3,剩3时先拿先赢(此时剩3拿2赢),拿3输;拿4剩2,剩2时先拿先赢(此时剩2拿1),拿4输
20  赢   拿1剩6,剩6输
19  赢   拿2剩6,剩6输
18  赢   拿3剩6,剩6输
17  10  赢   拿4剩6,剩6输
16  11  输   拿1剩10,剩10赢(此时剩10拿4赢),拿1输;拿2剩9,剩9时先拿先赢(此时剩9拿3赢),拿2输;拿3剩8,剩8时先拿先赢(此时剩8拿2赢),拿3输;拿4剩7,剩7时先拿先赢(此时剩7拿1),拿4输
15  12  赢   拿1剩11,剩11输
14  13  赢   拿2剩11,剩11输
13  14  赢   拿3剩11,剩11输
12  15  赢   拿4剩11,剩11输
11  16  输   拿1剩15,剩15赢(此时剩15拿4赢),拿1输;拿2剩14,剩14时先拿先赢(此时剩14拿3赢),拿2输;拿3剩13,剩3时先拿先赢(此时剩13拿2赢),拿3输;拿4剩12,剩12时先拿先赢(此时剩12拿1),拿4输
10  17  赢   拿1剩16,剩16输
18  赢   拿2剩16,剩16输
19  赢   拿3剩16,剩16输
20  赢   拿4剩16,剩16输
21  输   拿1剩20,剩20赢(此时剩20拿4赢),拿1输;拿2剩19,剩19时先拿先赢(此时剩19拿3赢),拿2输;拿3剩18,剩18时先拿先赢(此时剩18拿2赢),拿3输;拿4剩17,剩17时先拿先赢(此时剩17拿1),拿4输
22  赢   拿1剩21,剩21输
23  赢   拿2剩21,剩21输
24  赢   拿3剩21,剩21输
25  赢   拿4剩21,剩21输
26  输   拿1剩25,剩25赢(此时剩25拿4赢),拿1输;拿2剩24,剩24时先拿先赢(此时剩24拿3赢),拿2输;拿3剩23,剩23时先拿先赢(此时剩23拿2赢),拿3输;拿4剩22,剩22时先拿先赢(此时剩22拿1),拿4输

则可以看出,

当A+B=5n+1时,先拿者先输

当A+B=5n+2时,先拿者先赢,拿4

当A+B=5n+3时,先拿者先赢,拿3

当A+B=5n+4时,先拿者先赢,拿2

当A+B=5n时,先拿者先赢,拿1

结论:想要赢者,必须先拿1,当对手拿1、2、3、4时,先拿1者分别对应拿4、3、2、1必胜。

最新文章

  1. IOS - 响应者链条
  2. Makefile技术和应用总结
  3. HDU 1565 最大点权独立集
  4. 使用South时候由于两个相同id的文件引起的问题
  5. Android从网络下载文件
  6. PowerShell 转码函数 Default->UTF8
  7. BZOJ 3391: [Usaco2004 Dec]Tree Cutting网络破坏( dfs )
  8. SharePoint 2013的100个新功能之搜索(二)
  9. iOS开发frame, contentSize, contentOffset, contentInset 区别联系浅析
  10. CATransition 转场动画解析
  11. template might not exist or might not be accessible by any of the configured Template Resolvers
  12. puzz: 图片和表单上传的不一致问题
  13. ubuntu上vsftpd服务配置
  14. 用一颗学美术的心来理解PID调节
  15. 案例:Spark基于用户的协同过滤算法
  16. chunk writer 中需要对抛错的交易进行回滚,同时又要在其他表中记录是哪一笔交易记录失败
  17. 菜鸟教程之工具使用(二)——Maven打包非规范目录结构的Web项目
  18. zk分布式锁-排它锁简单实现
  19. iOS: 详细的正则表达式
  20. hdu_5187_zhx's contest

热门文章

  1. HTML入门1—HTML基础学习
  2. php session小节
  3. IOS NSOperationQueue(线程 封装操作)
  4. 使用browsermob代理出现错误java.lang.NoClassDefFoundError: org/littleshoot/proxy/HttpFiltersSource
  5. 使用selenium 检测js报错
  6. A. Kyoya and Colored Balls_排列组合,组合数
  7. javaweb基础(40)_jdbc框架
  8. SpringBoot发布WAR启动报错:Error assembling WAR: webxml attribute is required
  9. XML DTD约束 对xml文件的crud的查询Read Retrieve操作 xml递归遍历
  10. mpvue项目中安装weui