当前位置:编程学习 > C/C++ >>

anti_nim反尼姆博弈 hdu2509

 方法搞不懂啊 


几下来当模板:


#include<iostream>
using namespace std;
int main()
{
    int i,n,m;
    while(cin >> n)
    {
              int flag = 0; //判断是否是孤单堆
              int s = 0;
              for(i = 0;i < n;i++)
              {
                    cin >> m;
                    s ^= m;
                    if(m > 1)
                         flag = 1;
              }
              if(flag == 0)
                      if(n % 2)
                           cout << "No\n";
                      else
                           cout << "Yes\n";
              else
                  if(s == 0)
                      cout << "No" <<endl;
                  else
                      cout << "Yes" <<endl;
    }
    return 0;
}

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,