ZOJ 3958 Cooking Competition 题解

来源:互联网 发布:康麻子 知乎 编辑:程序博客网 时间:2024/06/06 06:50

题意

两个人比赛厨艺,有n个评委,每个评委可能给出4种评价,1表示A加1分,B不加分,2表示A不加分,B加1分,3表示两人各加1分,4表示两人各扣1分,问最后谁赢了比赛还是平局

思路

按题意用循环和判断模拟即可

代码

#include <iostream>#include <cstdio>using namespace std;int main(){    int T,a,b,n,t;    scanf("%d",&T);    while(T--)    {        scanf("%d",&n);        a=0;        b=0;        for(int i=0;i<n;i++)        {            scanf("%d",&t);            if(t==1)                a++;            else if(t==2)                b++;            else if(t==3)            {                a++;                b++;            }            else            {                a--;                b--;            }        }        if(a>b)            printf("Kobayashi\n");        else if(a==b)            printf("Draw\n");        else printf("Tohru\n");    }    return 0;}
0 0
原创粉丝点击