zoukankan      html  css  js  c++  java
  • HDU 2177

    http://acm.hdu.edu.cn/showproblem.php?pid=2177

    威佐夫博奕,面对奇异局势既bk=ak+k时是必败点,其中bk>=ak,k=bk-ak

    别的处理和其他博弈相同,注意题目的数据取一堆的时候数据有问题

    #include <iostream>
    #include <cstdio>
    #include <cmath>
    #include <map>
    
    using namespace std;
     
    int OK(int b, int k) {
        if(b == (int)(k * (1 + sqrt(5.0)) / 2) + k) return 1;
        return 0;
    }
     
    int main() {
        int a, b;
        while(~scanf("%d%d", &a, &b)) {
            if(!a && !b) break;
            if(a > b) swap(a, b);
            int k = b - a;
            if(OK(b, k)) puts("0");
            else {
                puts("1");
                int x, y;
                for(int i = 1; i <= a; i++) {
                    x = a - i, y = b - i;
                    if(OK(y, y-x)) printf("%d %d
    ", x, y);
                }
                map <int, int> mp;
                for(int i = 1; i <= b; i++) {
                    x = a - i, y = b;
                    if(x > 0 && OK(y, y-x) && mp[x]!=y) {
                        printf("%d %d
    ", x, y);
                        mp[x] = y;
                    }
                    x = a, y = b - i;
                    if(x > y) swap(x, y);
                    if(OK(y, y-x) && mp[x]!=y) {
                        printf("%d %d
    ", x, y);
                        mp[x] = y;
                    }
                }
            }
        }
        return 0;
    }
    View Code
  • 相关阅读:
    响应式一些知识
    自动显示git分支--安装oh-my-zsh(Ubuntu环境)
    一些感受吧
    vim 编辑器笔记
    gitlab 配置 ssh && ubuntu
    css3遇到的一些属性
    ajax 基础教程
    怎么查看浏览器内核
    简单理解锁
    测试项目注意项
  • 原文地址:https://www.cnblogs.com/xiaohongmao/p/4558083.html
Copyright © 2011-2022 走看看