首页 > 其他 > 详细

【HDU】1517 A Multiplication Game

时间:2015-02-06 23:10:20      阅读:363      评论:0      收藏:0      [点我收藏+]

http://acm.hdu.edu.cn/showproblem.php?pid=1517

题意:每次乘上2~9。。p>=n时赢..

#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

typedef long long ll;
map<ll, bool> h;
ll n;
bool dfs(ll p) {
	if(p>=n) return 0;
	if(h.count(p)) return h[p];
	for(int i=2; i<=9; ++i) if(!dfs(p*i)) return h[p]=1;
	return h[p]=0;
}
int main() {
	while(~scanf("%lld", &n)) {
		h.clear();
		dfs(1)?puts("Stan wins."):puts("Ollie wins.");
		//for(int i=1; i<=16; ++i) printf("%d: %d\n", i, h[i]);
	}
	return 0;
}

  


 

由于乘法在2~9的话深度是log级的= =而且很多无用状态= =开个map裸跑= =

 

【HDU】1517 A Multiplication Game

原文:http://www.cnblogs.com/iwtwiioi/p/4278136.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!