POJ
来源:互联网 发布:三维热传导模拟软件 编辑:程序博客网 时间:2024/06/04 21:08
威佐夫博奕
简述
威佐夫博弈(Wythoff Game):有两堆各若干个物品,两个人轮流从某一堆或同时从两堆中取同样多的物品,规定每次至少取一个,多者不限,最后取光者得胜。分析
我们用(ak,bk) (ak<=bk,k=0,1,2,~,n) 表示两堆物品的数量并称其为局势,如果甲面对(0,0) ,那么甲已经输了,这种局势我们称为奇异局势。前几个奇异局势是:(0,0)、(1,2)、(3,5)、(4,7)、(6,10)、(8,13)、(9,15)、(11,18)、(12,20)。可以看出:a0=b0=0,ak 是未在前面出现过的最小自然数,而bk=ak+k。必胜态必败态
满足 ak=k*(1+√5) /2,bk=ak+k,后手必胜,否则先手必胜。
例题:
POJ - 1067
代码:
#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>using namespace std;int main(){ int a,b; while(scanf("%d%d",&a,&b)!=EOF) { int bb=max(a,b); int aa=min(a,b); int k=bb-aa; int temp=(k*(1+sqrt(5))/2); if(aa==temp) printf("0\n"); else printf("1\n"); } return 0;}
阅读全文
0 0
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- Android中其他优化知识点
- jedis整合ssm
- tablayout导航栏
- python
- Windows编程基础- 设备对象属性
- POJ
- js 4种常用正则表达式
- 算法第二周Add Two Numbers[medium]
- Struts2-01-数据访问
- [poj 1679] The Unique MST---(翻译:次小生成树)
- 2017年9月17日训练总结
- hello world!
- [BZOJ]4419: [Shoi2013]发微博 set暴力
- 使用servlet导出excel表