PAT 1046 Guessing Game B (15 minutes)

Guessing Game 1046 (15 minutes)

Guessing Game is an interesting part of the ancient Chinese wine culture. Finger Guessing Game two of wine on the table method is: the mouth of a digital person shouted, while a hand than to draw a number. If the ratio figures who draw is exactly equal to the sum of the two numbers shouted, whoever wins, the loser penalty of one glass of wine. Both of them win or lose with the two proceed to the next round until only the winner appears.
Here are A, B two Guessing Game record, you count them separately how much to drink last glass of wine.
Input formats:

First input of the first row is given a positive integer N (≦ 100), followed by N rows, each row Huaquan a given recording format:
A call to call B B A draw stroke
wherein the call is a call for digital zoned It is to draw figures are positive integers no more than 100 (designated with two hands).
Output formats:

A successively output in a row, the number of cups of drink B two, with a space therebetween.
Sample input:

. 5
. 8. 9 12 is 10
. 5 10. 5 10
. 3. 5. 8 12 is
12 is 18 is 13 is. 1
. 4 16 12 is 15
sample output:

12
Author: CHEN, Yue
units: Zhejiang University
Time limit: 400 ms
Memory Limit: 64 MB
Code length limit: 16 KB

#include <iostream>
using namespace std;
int main(){
    int n,sum_jia,sum_yi,a,b,c,d;//a、b、c、d 分别是 甲喊 甲划 乙喊 乙划
    sum_jia =0;
    sum_yi = 0;
    cin>>n;
    for (int i = 0; i < n; ++i) {
        cin>>a>>b>>c>>d;
        if(b == a+c && d == a+c)
            continue;
        else{
            if(b == a+c)
                sum_yi++;
            else
                if(d == a+c)
                    sum_jia++;
        }
    }
    cout<<sum_jia<<" "<<sum_yi;
    return 0;
}
Published 101 original articles · won praise 50 · views 8284

Guess you like

Origin blog.csdn.net/qq_43422111/article/details/104106259