Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:通俗版异或原理

Posted by mingruoyuan at 2009-06-22 10:49:14 on Problem 2234
In Reply To:通俗版异或原理 Posted by:mingruoyuan at 2009-06-22 10:41:02
两种情况:必败情况与必胜情况。
如果现在处于必胜情况,那么如果到我取,我只要取适当的石子,使得剩下的变成必败情况就OK

那么什么是必败情况呢?其实就是所有堆石子数目按位异或位为0的时候。

显然,当你取完所有的石子后,剩下的是0,异或本身位0;
当只剩下一堆(不为0)的时候,异或不为0,只要取光就为0;
当剩下2堆的时候,除非两堆石子相等,否则异或不为0;那么只要取到两堆相等,把必败情况留给对手。

如此逆向推上。如果你处于必胜情况,也就是异或不为0时,只要取适当的石子,把异或变成0,也就是把必败情况留给对手,那么就赢定了。

嘿嘿,轻松搞定。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator