Mishka and Game

举报
辰chen 发表于 2022/06/15 01:14:38 2022/06/15
【摘要】 文章目录 一、A. Mishka and Game总结 一、A. Mishka and Game 本题链接:A. Mishka and Game 题目: A. Mishka and...


一、A. Mishka and Game

本题链接A. Mishka and Game

题目

A. Mishka and Game

time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output

Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.

Rules of the game are very simple: at first number of rounds n is defined. In every round each of the players throws a cubical dice with distinct numbers from 1 to 6 written on its faces. Player, whose value after throwing the dice is greater, wins the round. In case if player dice values are equal, no one of them is a winner.

In average, player, who won most of the rounds, is the winner of the game. In case if two players won the same number of rounds, the result of the game is draw.

Mishka is still very little and can’t count wins and losses, so she asked you to watch their game and determine its result. Please help her!

Input
The first line of the input contains single integer n n (1 ≤ n ≤ 100) — the number of game rounds.

The next n lines contains rounds description. i-th of them contains pair of integers mi and ci (1 ≤ mi,  ci ≤ 6) — values on dice upper face after Mishka’s and Chris’ throws in i-th round respectively.

Output
If Mishka is the winner of the game, print “Mishka” (without quotes) in the only line.

If Chris is the winner of the game, print “Chris” (without quotes) in the only line.

If the result of the game is draw, print “Friendship is magic!^^” (without quotes) in the only line.

Examples
input
3
3 5
2 1
4 2
output
Mishka

input
2
6 1
1 6
output
Friendship is magic!^^

input
3
1 5
3 3
2 2
output
Chris

Note
In the first sample case Mishka loses the first round, but wins second and third rounds and thus she is the winner of the game.

In the second sample case Mishka wins the first round, Chris wins the second round, and the game ends with draw with score 1:1.

In the third sample case Chris wins the first round, but there is no winner of the next two rounds. The winner of the game is Chris.

本博客给出本题截图
在这里插入图片描述
在这里插入图片描述
题意:比较大小,看谁赢的多,对应三种不同的输出结果

AC代码

#include <iostream>

using namespace std;

int cntm, cntc;

int main()
{
    int n;
    cin >> n;
    
    while (n -- )
    {
        int a, b;
        cin >> a >> b;
        
        if (a > b) cntm ++;
        else if (a < b) cntc ++;
        else 
        {
            cntm ++;
            cntc ++;
        }
    }
    
    if (cntc > cntm) 
        puts("Chris");
    else if (cntc == cntm)
        puts("Friendship is magic!^^");
    else
        puts("Mishka");
        
    return 0;
}

总结

水题,不解释

文章来源: chen-ac.blog.csdn.net,作者:辰chen,版权归原作者所有,如需转载,请联系作者。

原文链接:chen-ac.blog.csdn.net/article/details/119006908

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。