1046. Huaquan (15)
Huaquan is an interesting part of the ancient Chinese wine culture. Two people Huaquan on the table are: Each person's mouth shout out a number, at the same time by hand to figure out a number. If the figure is equal to the number of two people shouting the sum of the numbers, who wins, the loser penalty a glass of wine. Both win or lose with each other and continue the next round until the only winner appears.
Here are the Huaquan records for both A and B, please count how many glasses of wine they drank last.
Input format:
Enter the first line first to give a positive integer n (<=100), followed by n lines, each row gives a round of Huaquan records, in the form of:
A shout a row B shout B row
The "shout" is the number that is shouted out, and the number of "strokes" is a positive integer of not more than 100 (two hand strokes).
Output format:
In one row successively output A, B two people drink the number of cups, in the meantime separated by a space.
Input Sample:
58 10 9 125 10 5 103 8 5 1212 18 1 134 16 12 15
Sample output:
1 2
1#include <stdio.h>2 intMain ()3 {4 inttest,countj=0, county=0;5scanf"%d",&test);6 while(test--)7 {8 inta,b,c,d;9scanf"%d%d%d%d",&a,&b,&c,&d);Ten if(b==a+c&&d==a+c| | b!=a+c&&d!=a+c) One Continue;//without a winner, jump straight to the next inning . A Else if(b==a+c&&d!=a+c) -county++;//A win, B drinks . - Else if(b!=a+c&&d==a+c) thecountj++;//b win a drink - } -printf"%d%d\n", countj,county); - return 0; +}
1046. Huaquan (15)