关于博弈(OJ kiki'game)

本文介绍了一种基于博弈论的游戏,玩家需要将棋子从棋盘的右上角移动到左下角,每次可以向左、向下或左下移动。通过分析游戏规则,得出当棋盘大小为偶数时,初始玩家必胜的结论。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目描述:

Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin is placed in the top right corner(1,m). Each time one people can move the coin into the left, the underneath or the left-underneath blank space.The person who can't make a move will lose the game. kiki plays it with ZZ.The game always starts with kiki. If both play perfectly, who will win the game? 

输入:

Input contains multiple test cases. Each line contains two integer n, m (0<n,m<=2000). The input is terminated when n=0 and m=0. 

输出:

If kiki wins the game printf "Wonderful!", else "What a pity!". 

样例输入:

5 3

5 4

6 6

0 0

样例输出:

What a pity!

Wonderful!

Wonderful!


代码:

#include<stdio.h>
int main()
{
  int n,m;
  while(scanf("%d%d",&n,&m))
  {
    if(n==0||m==0) break;
    if(n%2==0||m%2==0)
    {
       printf("Wonderful!\n");
    }
       else
       printf("What a pity!\n");
  }
   return 0;
}


分析:本题其实是一道关于博弈的题目,从右下角往左上角推导,当n=m=2即为2*2方阵时,无论kiki或ZZ谁先进入这个2*2方阵就意味着谁输了,根据这一思路往上推得谁先处于n和m都为奇数的方格时,她就输了。

### 关于东方博弈 OJ 1817 题目解决方案 针对东方博弈平台上编号为1817的题目,虽然具体题干未在此提及,但从涉及的内容推测该题目可能属于算法或编程挑战的一部分。基于此类平台的一般特性以及提供的参考资料[^1],这类题目通常旨在考察参赛者的逻辑思维能力和编程技巧。 #### 可能的主题领域 考虑到所给定的其他引用材料主要集中在算法设计、特别是有关博弈论的应用方面[^2],可以合理推断OJ 1817也可能围绕着相似的概念展开。例如: - **动态规划** - **贪心算法** - **图论中的路径优化** #### 推测性的解决框架 假设这是一个典型的博弈问题,那么解决问题的一个常见途径就是通过递归来模拟不同玩家之间的交互过程,并利用记忆化技术来提高效率。下面给出一段伪代码作为概念验证: ```python def solve_game(state): # Base case: check if current state is a losing position if is_losing_state(state): return False # Try all possible moves from the current state for next_state in generate_all_possible_moves(state): # If there exists any move leading to opponent's loss, this is winning strategy if not solve_game(next_state): return True # No available move leads to win; hence it’s a losing situation here. return False ``` 这段代码体现了如何评估某个特定状态下是否存在胜利的可能性——即能否找到至少一条通向对方失败局面的道路。 #### 实际编码建议 当实际编写程序时,应当注意输入数据结构的设计,确保能够高效处理各种边界情况。此外,由于许多在线评测系统会对运行时间和内存消耗有严格限制,因此还需要考虑性能优化措施,比如剪枝不必要的分支或是采用迭代加深等高级搜索策略。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值