• 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
    
  • 相关阅读:
    ORACLE的程序包1程序包的基
    JAVA中方法重载,方法覆盖,方法继承等小结
    使用DBMS_JOB包创建ORACLE定时任务
    linux shell 中判断语句
    oracle direction目录
    Java加载类的加载顺序
    Struts2非常简单实用的身份验证功能
    关于ListView优化的一点心得
    使用webview将网页打包成apk
    关于android下的冒烟测试
  • 原文地址:https://www.cnblogs.com/liuziwen0224/p/2014d1t1.html
Copyright © 2020-2023  润新知