Cooking Competition

编程入门 行业动态 更新时间:2024-10-18 19:27:58

Cooking Competition

  • Cooking Competition
      • 题目解析
      • 题目描述
      • AC代码

题目解析

初始化两个数组 a[] = {1, 0, 1, -1}; b[] = {0, 1, 1, -1}; 输入数字减一为数组下标,sum累加比较即得答案

题目描述

“Miss Kobayashi’s Dragon Maid” is a Japanese manga series written and illustrated by Coolkyoushinja. An anime television series produced by Kyoto Animation aired in Japan between January and April 2017.

In episode 8, two main characters, Kobayashi and Tohru, challenged each other to a cook-off to decide who would make a lunchbox for Kanna’s field trip. In order to decide who is the winner, they asked n people to taste their food, and changed their scores according to the feedback given by those people.

There are only four types of feedback. The types of feedback and the changes of score are given in the following table.

TypeFeedbackScore Change (Kobayashi)Score Change (Tohru)
1Kobayashi cooks better+10
2Tohru cooks better0+1
3Both of them are good at cooking+1+1
4Both of them are bad at cooking-1-1

Given the types of the feedback of these n people, can you find out the winner of the cooking competition (given that the initial score of Kobayashi and Tohru are both 0)?

Input

There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 100), indicating the number of test cases. For each test case:

The first line contains an integer n (1 ≤ n ≤ 20), its meaning is shown above.

The next line contains n integers a1, a2, … , an (1 ≤ ai ≤ 4), indicating the types of the feedback given by these n people.

Output

For each test case output one line. If Kobayashi gets a higher score, output “Kobayashi” (without the quotes). If Tohru gets a higher score, output “Tohru” (without the quotes). If Kobayashi’s score is equal to that of Tohru’s, output “Draw” (without the quotes).

Sample Input

2
3
1 2 1
2
3 4

Sample Output

Kobayashi
Draw

Hint

For the first test case, Kobayashi gets 1 + 0 + 1 = 2 points, while Tohru gets 0 + 1 + 0 = 1 point. So the winner is Kobayashi.

For the second test case, Kobayashi gets 1 - 1 = 0 point, while Tohru gets 1 - 1 = 0 point. So it’s a draw.

AC代码

#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
    int a[] = {1, 0, 1, -1};
    int b[] = {0, 1, 1, -1};
    int t;
    cin >> t;
    while(t--) {
        int n, flag, suma = 0, sumb = 0;
        cin >> n;
        while(n--) {
            cin >> flag;
            suma += a[flag - 1];
            sumb += b[flag - 1];
        }
        if(suma > sumb)
            cout << "Kobayashi" <<endl;
        else if(suma < sumb)
            cout << "Tohru" << endl;
        else
            cout << "Draw" << endl;
    }
    return 0;
}

更多推荐

Cooking Competition

本文发布于:2023-06-13 19:52:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1398174.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Cooking   Competition

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!