Hdoj 2509 Be the Winner
2021-02-11 00:16
阅读:567
Diciption
Let‘s consider m apples divided into n groups. Each group contains no more than 100 apples, arranged in a line. You can take any number of consecutive apples at one time.
For example "@@@" can be turned into "@@" or "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is
the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
For example "@@@" can be turned into "@@" or "@" or "@ @"(two piles). two people get apples one after another and the one who takes the last is
the loser. Fra wants to know in which situations he can win by playing strategies (that is, no matter what action the rival takes, fra will win).
Input
You will be given several cases. Each test case begins with a single number n (1 Output
If a winning strategies can be found, print a single line with "Yes", otherwise print "No".
Sample Input
2 2 2 1 3
Sample Output
No Yes
anti_nim游戏。
这种Nim是不能操作者赢。
Sg函数的话还是和普通的Nim一样,初始化是sg[0]=0;
最后游戏的和的话,先手必胜当且仅当:
1.每一堆石子都是1并且Nim和为0.
2.有至少一堆石子>1并且Nim和不为0.
#include#define ll long long using namespace std; int sg[105],n,m; int now,v[1005]; inline void init(){ sg[0]=0; for(int i=1;i1) flag=1; } if((!flag&&!ans)||(flag&&ans)) puts("Yes"); else puts("No"); } return 0; }
上一篇:salt-api安装配置及使用
下一篇:(45)C#搭建邮件服务器
文章来自:搜素材网的编程语言模块,转载请注明文章出处。
文章标题:Hdoj 2509 Be the Winner
文章链接:http://soscw.com/index.php/essay/53800.html
文章标题:Hdoj 2509 Be the Winner
文章链接:http://soscw.com/index.php/essay/53800.html
评论
亲,登录后才可以留言!