Given below a, b two people's capacity for liquor (at most) can drink how much cup and building-would records, would you please determine two men who first down,
Input format:
Enter the first line has given a, b two people drink of the nonnegative integers (no more than 100), separated by Spaces, the next row is given a positive integer N (100) or less, then N lines, each line give a round of building-would records, format for:
A shout a cross b shout b row
Among them is shout shout out Numbers, row is drawn Numbers, are all positive integers less than 100 (two hands row),
The output format:
Output in the first row, first the man fall: on behalf of A and B on behalf of B, the second line of the output the man standing drink how much cup, ensure that there is A person fall, pay attention to the process end, someone fell behind the data don't have to deal with,
Input:
1 1
6
8 9 10 12
5 to 10 10
3 August 5 12
12 18 1 13
4 16 12 15
15 1 1 16
Output:
A
1
Please ask how this programming problem!
With the method of the Python!!!!!
CodePudding user response:
result=[[0, False, 'A'], [0, False, 'B']]
With the open (r 'c: \ ZZZ. TXT', encoding="utf-8", mode='r +') as f:
L=f.r ead (.) splitlines ()
A, B=map (int, l [0]. The split ())
The count=int (l [1])
For I in range (count) :
Aj, Ah, Bj, Bh=map (int, l [2 + I]. The split ())
If Aj + Bj Bj====Ah and Aj + Bh:
The continue
Elif Aj + Bj!=Ah and Aj + Bj!=Bh:
The continue
Elif Aj + Bj==Ah and Aj + Bj!=Bh:
The result [0] [0] +=1
The else:
The result [1] [0] +=1
If the result [0] [0] & gt; A:
The result [0] [1]=True
Break
If the result [1] [0] & gt; B:
The result [1] [1]=True
Break
Print (STR (list (filter (lambda x: x [1], the result)) [0] [2]))
Print (STR (list (filter (lambda x: not x [1], the result)) [0] [0]))
This mean?
CodePudding user response:
A_limit b_limit=[int (x) for x input in (). The split ()]
N=int (input ())
A_count=0
B_count=0
For I in range (n) :
TMP=[int (x) for x input in (). The split ()]
If TMP TMP [0] + [2]==TMP [1] and TMP [0] + TMP [2].=TMP [3] :
A_count +=1
Elif TMP + TMP [0] [2].=TMP [1] and TMP [0] + TMP [2]==TMP [3] :
B_count +=1
If a_count & gt; A_limit:
Print (' A ')
Print (b_count)
Break
Elif b_count & gt; B_count:
Print (' B ')
Print (a_count)
Break
Probably like this
CodePudding user response:
Okok, done, thank youCodePudding user response: