zoukankan      html  css  js  c++  java
  • Gym 101666I Irrational Division(博弈)

    Gym 101666I Irrational Division

    Description

    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.)

    Input

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

    Output

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

    Sample Input 1

    1 2 
    

    Sample Output 1

    2
    

    Sample Input 2

    2 2 
    

    Sample Output 2

    0
    

    Sample Input 3

    4 3 
    

    Sample Output 3

    0
    

    题解

    题意

    两人博弈,不对称博弈,一人横切,一人竖切。没有可操作的步骤后终结,黑巧克力+1幸福度,白巧克力-1幸福度。问两人最大幸福度差值。

    思路

    之后绘图补

    代码

    #include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<cstdlib>
    #include<cmath>
    #include<cstring>
    #include<queue>
    #include<vector>
    #include<map>
    using namespace std;
    #define ll long long
    #define maxn 100010
    #define yyj(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
    
    ll n,m;
    int main()
    {
    	cin>>n>>m;
    	if (n%2==1 && m%2==0&&n<m) {cout<<2; return 0;}
    	else if (n%2 && m%2) cout<<1;
    	else cout<<0;
    	return 0;
    }
    
  • 相关阅读:
    一种 动态 样式 语言. LESS 将 CSS 赋予了动态语言的特性,如 变量, 继承, 运算, 函数. LESS 既可以在 客户端 上运行 (支持IE 6+, Webkit, Firefox),也可以借助Node.js或者Rhino在服务端运行。
    关于jquery选择器的一些注意
    几种序列化协议(protobuf,xstream,jackjson,jdk,hessian)相关数据对比
    测试:你自认为理解了JavaScript?
    如何移除相邻两个 display: inlineblock 元素间的间隔
    Linux TCP 连接数修改
    CSS lineheight 和 verticalalign 精解(上篇)_依然梦想_百度空间
    pageX,clientX,offsetX,layerX的那些事
    在html5下 关于img与div之间的缝隙
    iframe自适应高度详解(希望对大家有用)
  • 原文地址:https://www.cnblogs.com/caomingpei/p/9694241.html
Copyright © 2011-2022 走看看