zoukankan      html  css  js  c++  java
  • 2014D1T1 生活大爆炸版石头剪刀布

    2014D1T1 生活大爆炸版石头剪刀布

    problem&solution

    暴力模拟,循环数组。胜负条件看好。

    code

    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    #include <cstring>
    using namespace std;
    const int maxn=1e4;
    int read(){
    	int op=1,ans=0;char c;
    	c=getchar();
    	for(;(c<'0'||c>'9')&&c!='-';c=getchar());
    	if(c=='-') op=-1,c=getchar();
    	for(;c>='0'&&c<='9';c=getchar()) ans*=10,ans+=c^48;
    	return ans*op;
    }
    int n,na,nb,awin=0,bwin=0;
    int a[maxn],b[maxn];
    int check(int a,int b){
    	if(a==0){
    		if(b==0) return 0;
    		else if(b==1) return -1;
    		else if(b==2) return 1;
    		else if(b==3) return 1;
    		else if(b==4) return -1;
    	}
    	else if(a==1){
    		if(b==0) return 1;
    		else if(b==1) return 0;
    		else if(b==2) return -1;
    		else if(b==3) return 1;
    		else if(b==4) return -1;
    	}
    	else if(a==2){
    		if(b==0) return -1;
    		else if(b==1) return 1;
    		else if(b==2) return 0;
    		else if(b==3) return -1;
    		else if(b==4) return 1;
    	}
    	else if(a==3){
    		if(b==0) return -1;
    		else if(b==1) return -1;
    		else if(b==2) return 1;
    		else if(b==3) return 0;
    		else if(b==4) return 1;
    	}
    	else if(a==4){
    		if(b==0) return 1;
    		else if(b==1) return 1;
    		else if(b==2) return -1;
    		else if(b==3) return -1;
    		else if(b==4) return 0;
    	}
    }
    int main(){
    	n=read(),na=read(),nb=read();
    	//printf("%d %d %d
    ",n,na,nb);
    	for(int i=1;i<=na;i++) a[i]=read();
    	for(int i=1;i<=nb;i++) b[i]=read();
    	a[0]=a[na],b[0]=b[nb];
    	for(int i=1;i<=n;i++) a[i]=a[i%na];
    	for(int i=1;i<=n;i++) b[i]=b[i%nb];
    	for(int i=1;i<=n;i++){
    		int u=check(a[i],b[i]);
    		//printf("%d
    ",u);
    		if(u==1) awin++;
    		else if(u==-1) bwin++;
    	}
    	printf("%d %d",awin,bwin);
    	return 0;
    }
    //0 scissors 1 rock 2 paper 3 xiyi 4 siboke
    
  • 相关阅读:
    FxCopCmd.exe 返回错误代码 65[翻译]
    关于VS2005安装项目制作的三个参考文章链接
    Windows服务开发的四个小经验
    ThreadLocal详解
    java修饰符详解
    聚合、组合、关联、继承之间的区别【转】
    centos单用户模式修改ROOT密码
    vim的配置
    spring注解详解
    centOS修改文本界面分辨率
  • 原文地址:https://www.cnblogs.com/liuziwen0224/p/2014d1t1.html
Copyright © 2011-2022 走看看