码迷,mamicode.com
首页 > 其他好文 > 详细

poj 2505 乘法博弈论

时间:2018-04-17 11:29:52      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:ace   div   str   .com   htm   lse   博弈论   highlight   amp   

转自:http://hzwer.com/1921.html

题目大意:

题意:Stan从1开始,可以乘上2~9中任何一个数,Ollie也如此操作,只到某个人本回合的操作超过N为之。。1<N<2^32-1

 基本思路:

找到Stan的必败状态,[10,18],[163,324]……[9^n*2^(n-1)+1,9^n*2^n]

分析:

0-9:stan

10-18:ollie

19-162:stan

163-324:ollie

规律:

9 = 9

18 =2*9

162 = 9*2*9

324 = 2*9*2*9

...

代码如下:

#include<iostream>
#include<cstdio>
using namespace std;
double n;
int main()
{
	while(scanf("%lf",&n)!=EOF)
	{
		while(1)
		{
			if(n<=9){printf("Stan wins.\n");break;}
			else if(n<=18){printf("Ollie wins.\n");break;}
			n/=18;
		}
	}
	return 0;
}

  

poj 2505 乘法博弈论

标签:ace   div   str   .com   htm   lse   博弈论   highlight   amp   

原文地址:https://www.cnblogs.com/imzscilovecode/p/8861764.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!