山东省第八届ACM省赛A.Return of the Nim
2017-05-29 16:39
375 查看
题目
当n=2的时候是威佐夫博弈。其他时候都是nim博弈。(说起来多容易,呵呵哒)
当n=2的时候是威佐夫博弈。其他时候都是nim博弈。(说起来多容易,呵呵哒)
#include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int a[35]; int main() { int t; while(~scanf("%d",&t)) { int n; while(t--) { scanf("%d",&n); memset(a,0,sizeof a); if(n==2) { int a,b; scanf("%d %d",&a,&b); int x=max(a,b); int y=min(a,b); int z=x-y; int w=(int)(((sqrt(5)+1)/2)*z); if(w==y) printf("Watson\n"); else printf("Sherlock\n"); continue; } int ans=0; for(int i=0;i<n;i++) { scanf("%d",&a[i]); ans^=a[i]; } if(ans==0) printf("Watson\n"); else printf("Sherlock\n"); } } }
相关文章推荐
- 山东省第八届acm省赛 Return of the Nim
- Return of the Nim----Nim博弈+威佐夫博弈 山东省第八届省赛A题
- 2017年ACM第八届山东省赛A题:Return of the Nim
- ACM 第八届山东省赛 A题 Return of the Nim
- 山东省第八届省赛 Return of the Nim(博弈)
- 山东省第八届省赛A题 Return of the Nim
- 【补题】2017山东省赛A题 Return of the Nim
- 2013山东省第四届ACM省赛 The number of steps
- 山东省第八届ACM省赛 G 题 sum of power 解答
- Return of the Nim 山东省赛
- 山东省第四届ACM大学生程序设计竞赛 The number of steps 概率dp
- Sdut 2409 The Best Seat in ACM Contest(山东省第三届ACM省赛 H 题)(模拟)
- 山东省第八届ACM省赛 F 题(quadratic equation)
- Return of the Nim
- 省SD2017 A Return of the Nim【威佐夫博弈+NIM】
- [置顶] 2017年山东省第八届acm省赛总结
- 第八节省赛题解-Return of the Nim(尼姆博奕)
- 2016山东省第七届acm省赛 G题Triple Nim
- 山东省第八届ACM省赛 K 题 CF (排序01背包)
- 第四届 山东省ACM The number of steps (概率dp 待整理)