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

初学博弈,,留名,,,,,

Posted by yy17yy at 2011-05-07 16:21:41 on Problem 2505
据我理解,,,博弈的一大类的解题办法是寻找必败点,,,,,

可以用sg函数,,但是这个题数据量大,,,不好弄,,,但是可以一步步的推出来,,,

依题意,,,设输入的数为n,,,那么我们知道了一个必败点,,,x>=n,,,,因为这个时候游戏已经结束了,,,
然后因为凡是能推出必败点的点一定是必胜点,,,那么就有了一个区间[(n+8)/9,n-1]内的点为必胜点,,,,那么可知,,区间[(p+1)/2,p-1](其中p=(n+8)/9;)内的点为必败点,,,,因为这个区间内的点,,不管怎么乘,,得到的数都属于[(n+8)/9,n-1],,再继续推,,一直到算出1是属于必胜点还是必败点,,,

之所以能这么推,,是因为一个点的后继点一定属于刚确定下来的区间,,,就是说如果能满足这样的条件,,我们就可以这样推,,否则还是用sg函数吧,,,,,

#include <iostream>
using namespace std;
int main()
{
	__int64 p;
	while(~scanf("%I64d",&p))
	{
		int t=0;
		while(p!=1)
		{
			if(t%2==0)
				p=(p+8)/9;
			else
				p=(p+1)/2;
			t++;
		}
		puts(t%2?"Stan wins.":"Ollie wins.");
	}
	return 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