zoukankan      html  css  js  c++  java
  • 洛谷 P1328 生活大爆炸版石头剪刀布 模拟

    很简单
    Code:

    #include<cstdio>
    #include<queue>
    using namespace std;
    queue<int>A;
    queue<int>B;
    int n;
    int a,b;
    void input(){
        scanf("%d",&n);
        scanf("%d%d",&a,&b);
        for(int i=1;i<=a;i++){
            int v;
            scanf("%d",&v);
            A.push(v);
        }
        for(int i=1;i<=b;i++){
            int v;
            scanf("%d",&v);
            B.push(v);
        }
    }
    int judge_A(int v1,int v2){
        if(v1==v2)return 0;
        if(!v1){
           if(v2==1||v2==4)return 0;
           return 1;
        }
        if(v1==1){
            if(v2==2||v2==4)return 0;
            return 1;
        }
        if(v1==2){
            if(!v2||v2==2||v2==3)return 0;
            return 1;
        }
        if(v1==3){
            if(!v2||v2==1)return 0;
            return 1;
        }
        if(v1==4){
            if(v2==2||v2==3)return 0;
            return 1;
        }
    }
    int main(){
        input();
        int tot_a=0,tot_b=0;
        for(int i=1;i<=n;i++){
            int v1=A.front();
            int v2=B.front();
            tot_a+=judge_A(v1,v2);
            tot_b+=judge_A(v2,v1);
            A.pop();
            B.pop();
            A.push(v1);
            B.push(v2);
        }
        printf("%d %d
    ",tot_a,tot_b);
    }
  • 相关阅读:
    活动安排问题
    CodeForces
    HDU
    HDU
    HihoCoder
    二分签到题--二分入门
    并查集,最小生成树
    spark和 mapreduce的比较
    SparkSQL--数据源Parquet的加载和保存
    SparkSQL -DataFrame与RDD的互转
  • 原文地址:https://www.cnblogs.com/guangheli/p/9845192.html
Copyright © 2011-2022 走看看