5447: Irrational Division

时间限制(普通/Java):1000MS/3000MS     内存限制:65536KByte

描述

Your family has been blessed with chocolate! A huge piece of chocolate has been given to you and your sister to share. However, as you gobbled up the large majority last time, your parents have invented a game to keep things fair (and to keep you occupied while they hide all the other chocolate). To keep things interesting, they have given you a rectangular piece of chocolate, which consists of little squares of both dark chocolate and white chocolate in a chessboard pattern. While you and your sister both love dark chocolate, you hate white chocolate! So, both you and your sister want as much dark chocolate as possible, while simultaneously obtaining as little white chocolate as possible. Every dark piece of chocolate you obtain gives you 1 meaningless unit of happiness, while a white piece lowers your happiness by 1 meaningless unit (and the same holds for your sister). Now, while you love your sister very much, there is always heavy competition between siblings, so your goal is to maximize the difference of your obtained happiness and her obtained happiness (while she tries to do the opposite, obviously).

The game works as follows. Your parents place a p×q-rectangle of the aforementioned mixed chocolate on a table. You are situated on the west side of the table and your sister on the south side. The side of length p is parallel to the north-south line, while the side of length q is parallel to the east-west line. Furthermore, the north-west square is made of dark chocolate. Then, starting with yourself, you take turns breaking off blocks of chocolate (which you can keep). You can break off any positive number of entire columns from the west side, while your sister breaks off any positive number of entire rows from the south side. You repeat this process until no more chocolate is left. Your sister is very smart and will always play the game perfectly.

A game might proceed like this, for example: you and your sister start with a 3 ×4-rectangle. You decide to break off 2 columns, obtaining 3 dark and 3 white chocolate squares, netting a happiness of zero. Your sister then breaks off 1 row, obtaining 1 dark and 1 white squares as well, so no happiness for her either. You then take a single column, which nets you nothing again, after which your sister decides to break off one row, which nets her 1 happiness! You then take the last piece, which makes you lose a unit of happiness, so your total score is −1 − 1 = −2. See the figure. (Note: the strategies used here might not be optimal.)

输入

Multiple cases.

Each case given are two positive integers p and q, both at most 100, the height and width of the chocolate rectangle.

输出

Each case output the largest possible difference (in your favour) between your net happiness and your sister’s net happiness.

样例输入

1 2

样例输出

2

题目来源

BAPC 2017

题目链接:http://tzcoder.cn/acmhome/problemdetail.do?&method=showdetail&id=5447

题目大意:有一块黑白交替的巧克力,黑色的巧克力幸福值+1,白色巧克力幸福值-1,一人可以选任意行,一人可以选任意列,求两人幸福值的差值。

根据题目进行博弈模拟后发现结果只会存在0 1 2这3种情况

m为偶数b为奇数并且m>n时两人一人为1分1人为-1分,差值为2

m和n都是奇数是,一人为1分一人人为0分,差值为1

其他情况两人分数一样,差值为0

#include <bits/stdc++.h>
using namespace std;
int main(){int n,m;while(cin>>n>>m){if(!(m&1)&&(n&1)&&m>n)puts("2");else if((n&1)&&(m&1))puts("1");else puts("0");}
}

转载于:https://www.cnblogs.com/Anidlebrain/p/10029265.html

TZOJ--5447: Irrational Division (博弈)相关推荐

  1. 清华姚班“斩获”AAAI 2020最佳学生论文:首届弟子贝小辉携手本科在读李子豪,攻坚算法博弈研究...

    本文经AI新媒体量子位(公众号ID:qbitai)授权转载,转载请联系出处 本文约1700字,建议阅读5分钟 江湖英雄辈出,又是姚班少年郎. 江湖英雄辈出,又是姚班少年郎. 第34届美国人工智能协会年 ...

  2. LeetCode 1690. 石子游戏 VII(博弈DP)

    文章目录 1. 题目 2. 解题 1. 题目 石子游戏中,爱丽丝和鲍勃轮流进行自己的回合,爱丽丝先开始 . 有 n 块石子排成一排.每个玩家的回合中,可以从行中 移除 最左边的石头或最右边的石头,并获 ...

  3. LeetCode 486. 预测赢家(博弈DP)

    文章目录 1. 题目 2. 解题 1. 题目 给定一个表示分数的非负整数数组. 玩家 1 从数组任意一端拿取一个分数,随后玩家 2 继续从剩余数组任意一端拿取分数,然后玩家 1 拿,-- . 每次一个 ...

  4. LeetCode 810. 黑板异或游戏(博弈推理)

    1. 题目 一个黑板上写着一个非负整数数组 nums[i] . 小红和小明轮流从黑板上擦掉一个数字,小红先手. 如果擦除一个数字后,剩余的所有数字按位异或运算得出的结果等于 0 的话,当前玩家游戏失败 ...

  5. LeetCode 1025. 除数博弈(动态规划)

    1. 题目 爱丽丝和鲍勃一起玩游戏,他们轮流行动.爱丽丝先手开局. 最初,黑板上有一个数字 N .在每个玩家的回合,玩家需要执行以下操作: 选出任一 x,满足 0 < x < N 且 N ...

  6. 博弈论(2)例题:混合策略+完全信息动态博弈+可置信性与序贯理性 (研究生院的竞争/否决权/技术应用) Steven Tadelis - Game Theory. An Introduction

    这些都是之前上课的作业,就是做个整理(我按照作业分章节的),也希望能帮助大家学习叭~ 作业会附上部分中文题目和英文(就是检索内容,具体的题目全部贴图,打公式真的太难了555),有些公式可能有点问题,我 ...

  7. POJ1067_取石子游戏_威佐夫博弈

    /* *State: 1067 Accepted 176K 16MS C++ 435B *题目大意: * 威佐夫博弈 *解题思路: * 略. */ #include <iostream> ...

  8. Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)

    Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...

  9. BZOJ2275[Coci2010]HRPA——斐波那契博弈

    题目描述 N个石子,A和B轮流取,A先.每个人每次最少取一个,最多不超过上一个人的个数的2倍. 取到最后一个石子的人胜出,如果A要有必胜策略,第一次他至少要取多少个. 输入 第一行给出数字N,N< ...

  10. 博弈最高位POJ 1704(Georgia and Bob-Nim博弈)

    新手发帖,很多方面都是刚入门,有错误的地方请大家见谅,欢迎批评指正 Georgia and Bob Time Limit: 1000MS   Memory Limit: 10000K Total Su ...

最新文章

  1. 数据仓库的架构与设计
  2. 自定义图片验证码认证过滤器
  3. 小红书shield算法分析
  4. Genymotion设置代理至BurpSuite和Charles
  5. 我的世界服务器里怎么无限随机传送,我的世界随机传送插件使用教程 权限指令分享...
  6. Linux定时任务Crontab命令详解
  7. docker公共存储库_Docker Hub公共镜像仓库的使用
  8. 深度学习Dubbo系列(入门开篇)
  9. vs2019 product key
  10. 190627每日一句南京创新周;那些绝对不会失败的人,是永远不去尝试的人
  11. Latex排版论文——傻瓜式操作一晚排出毕业论文
  12. 阿里国际站的营销能力等级到底有什么用?我们又能操作些什么?
  13. 两台计算机如何组成局域网,两台电脑如何建立局域网
  14. 《自己动手写cpu》读书笔记
  15. yarn application -kill application_id yarn kill 超时任务脚本
  16. jQuery自动补全邮箱后缀列表插件
  17. 沧小海深入剖析xilinx的GTP/GTX核,掌握高速串行收发机制——第六章 接收端结构及功能说明
  18. 定时跑视图往另外一张表添加数据_聊一聊数据库中的锁
  19. 《知识图谱》赵军 学习笔记
  20. Java 调用 有道翻译API

热门文章

  1. 森林防火火灾漫延算法 火灾推演算法分析 火灾蔓延范围计算方法 森林火灾边界漫延计算方法
  2. 工业互联网大数据之数据管理与治理的简易理解
  3. 统计学习方法第一章思维导图
  4. 001Diamond学习002使用
  5. 【读书】格鲁夫给经理人的第一课-管理杠杆率
  6. MATLAB-损失函数和模型质量度量
  7. Python刷博客简易版
  8. 尾气冒黑烟是什么问题_汽车排气管冒黑烟,怎么回事?
  9. JavaScript 手写函数柯里化 curry
  10. 掌握这些常见的数据可视化表达方式,成为可视化达人!