A
The mounting was sober and annoying. It seems easy to implement if you listen to the explanation and remove the counterexample. I used Counter.
from collections import Counter
a = Counter(map(int,input().split()))
if 2 in a.values():
print("Yes")
else:
print("No")
B Implementation is not so difficult due to the upper limit of the number of inputs. I want to be able to combine if statements into one.
N = int(input())
A = list(map(int,input().split()))
for a in A:
if a % 2 == 1:
continue
if a % 3 != 0 and a % 5 != 0:
print("DENIED")
exit()
print("APPROVED")
C Save the most frequent occurrences in a variable. After that, only the sorted character strings that match the maximum number of times are displayed.
from collections import Counter
N = int(input())
S = Counter(input() for _ in range(N))
S = S.most_common()
most_count = S[0][1]
S.sort()
for i in range(len(S)):
if S[i][1] == most_count:
print(S[i][0])
D I had a bad feeling when I saw the problem statement, so I went to the standings. Most people prioritized E over D, so skip
E I skipped D, but I couldn't implement it. This is not good.
Recommended Posts