zoukankan      html  css  js  c++  java
  • HDU 2176 基础NIM 输出方案

    普通的NIM,然后问先手必胜第一次操作后的所有局面。

    对于一个必胜局面只要转变局面SG值为必败(SG=0)留给后手就行了。

    /** @Date    : 2017-10-13 21:39:13
      * @FileName: HDU 2176 基础NIM 输出方案.cpp
      * @Platform: Windows
      * @Author  : Lweleth (SoungEarlf@gmail.com)
      * @Link    : https://github.com/
      * @Version : $Id$
      */
    #include <bits/stdc++.h>
    #define LL long long
    #define PII pair
    #define MP(x, y) make_pair((x),(y))
    #define fi first
    #define se second
    #define PB(x) push_back((x))
    #define MMG(x) memset((x), -1,sizeof(x))
    #define MMF(x) memset((x),0,sizeof(x))
    #define MMI(x) memset((x), INF, sizeof(x))
    using namespace std;
    
    const int INF = 0x3f3f3f3f;
    const int N = 2e5+20;
    const double eps = 1e-8;
    
    int a[N];
    int main()
    {
    	int n;
    	while(~scanf("%d", &n) && n)
    	{
    		int ans = 0;
    		for(int i = 0; i < n; i++)
    			scanf("%d", a + i), ans ^= a[i];
    		if(ans == 0)
    		{
    			printf("No
    ");
    			continue;
    		}
    		printf("Yes
    ");
    		for(int i = 0; i < n; i++)
    		{
    			int t = ans ^ a[i];
    			if(t >= a[i])
    				continue;
    			else 
    				printf("%d %d
    ", a[i], t);
    		}
    	}
        return 0;
    }
    
  • 相关阅读:
    【现在还没补的比赛及题解】
    【刷题中】
    【寒假的待填的坑】
    【python】爬虫实践
    【python】vscode python环境配置
    【spring学习笔记二】Bean
    【spring学习笔记一】Ioc控制反转
    【2018CCPC秦皇岛】
    【2018ICPC沈阳】
    【2018ICPC青岛】
  • 原文地址:https://www.cnblogs.com/Yumesenya/p/7679020.html
Copyright © 2011-2022 走看看