洛谷P1328 生活大爆炸版石头剪刀布——S.B.S.
2016-05-02 16:46
239 查看
题目描述
石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头。如果两个人出拳一样,则不分胜负。在《生活大爆炸》第二季第8 集中出现了一种石头剪刀布的升级版游戏。
升级版游戏在传统的石头剪刀布游戏的基础上,增加了两个新手势:
斯波克:《星际迷航》主角之一。
蜥蜴人:《星际迷航》中的反面角色。
这五种手势的胜负关系如表一所示,表中列出的是甲对乙的游戏结果。
View Code
石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头。如果两个人出拳一样,则不分胜负。在《生活大爆炸》第二季第8 集中出现了一种石头剪刀布的升级版游戏。
升级版游戏在传统的石头剪刀布游戏的基础上,增加了两个新手势:
斯波克:《星际迷航》主角之一。
蜥蜴人:《星际迷航》中的反面角色。
这五种手势的胜负关系如表一所示,表中列出的是甲对乙的游戏结果。
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std;//0 表示“剪刀”,1 表示“石头”,2 表示“布”,3 表示“蜥蜴人”, 4 表示“斯波克” int pd(int,int); int main() { int da=0,db=0,s,n,na,nb,a[201]={0x7f},b[201]={0x7f},heada=0,taila=1,headb=0,tailb=1; cin>>n>>na>>nb;taila=na+1;tailb=nb+1; for(int i=1;i<=na;i++) cin>>a[i]; for(int i=1;i<=nb;i++) cin>>b[i]; for(int i=1;i<=n;i++) { heada++;headb++; if(heada==taila) heada=1; if(headb==tailb) headb=1; s=pd(a[heada],b[headb]); if(s==1) da++; if(s==-1) db++; s=0; } cout<<da<<" "<<db; return 0; } int pd(int aa,int bb) { if(aa==0&&bb==0) return 0; if(aa==0&&bb==1) return -1; if(aa==0&&bb==2) return 1; if(aa==0&&bb==3) return 1; if(aa==0&&bb==4) return -1; if(aa==1&&bb==0) return 1; if(aa==1&&bb==1) return 0; if(aa==1&&bb==2) return -1; if(aa==1&&bb==3) return 1; if(aa==1&&bb==4) return -1; if(aa==2&&bb==0) return -1; if(aa==2&&bb==1) return 1; if(aa==2&&bb==2) return 0; if(aa==2&&bb==3) return -1; if(aa==2&&bb==4) return 1; if(aa==3&&bb==0) return -1; if(aa==3&&bb==1) return -1; if(aa==3&&bb==2) return 1; if(aa==3&&bb==3) return 0; if(aa==3&&bb==4) return 1; if(aa==4&&bb==4) return 0; if(aa==4&&bb==0) return 1; if(aa==4&&bb==1) return 1; if(aa==4&&bb==2) return -1; if(aa==4&&bb==3) return -1; }
View Code
相关文章推荐
- C++继承:公有,私有,保护
- UVa 673 Parentheses Balance -SilverN
- UVa 297 Quadtrees -SilverN
- NOIP2010提高组 机器翻译 -SilverN
- NOIP2010提高组乌龟棋 -SilverN
- NOIP2009 提高组T3 机器翻译 解题报告-S.B.S
- NOIP2010普及组 三国游戏 -SilverN
- #include <NOIP2008 Junior> 双栈排序 ——using namespace wxl;
- #include <NOIP2009 Junior> 细胞分裂 ——using namespace wxl;
- 【NOIP合并果子】uva 10954 add all【贪心】——yhx
- 【NOIP提高组2015D2T1】uva 714 copying books【二分答案】——yhx
- git学习记录--merge
- mxgraph进阶(二)mxgraph的初步介绍与开发入门
- noip2014提高组day2二题题解-rLq
- NOIP2010普及组T4 三国游戏——S.B.S.
- NOIP2008 T3 传纸条 解题报告——S.B.S.
- NOIP2009普及组细胞分裂(数论)——yhx
- uva 11572 unique snowflakes——yhx
- uva 1471 defence lines——yhx
- NOIP2010普及组T3 接水问题 ——S.B.S.