题解 CF703A 【Mishka and Game】

· · 题解

到现在见到的为数不多的水题之一
当然CF还有很多有趣的题
下见代码:

#include<iostream>
using namespace std;
int main(){
    int n,a,b,cnt=0;  //cnt拿来计数
    cin>>n;
    for (int i=1;i<=n;i++) {
        cin>>a>>b;
        if (a>b) cnt++;  //若Mishka胜则++
        else if (a<b) cnt--;  //不要直接写else,会WA,这里要在判断并--
        else cnt=cnt;  //打平则不动
    }  //下面根据题意简单判断
    if (cnt>0) cout<<"Mishka";  
    else if (cnt<0) cout<<"Chris";
    else cout<<"Friendship is magic!^^";
}