AtCoder Beginner Contest 155 過去問(A~C)

A問題

特に問題なし

a = list(map(int, input().split()))
if len(set(a))==2: print('Yes')
else: print('No')

B問題

特に問題なく

n = int(input())
aa = list(map(int, input().split()))
for a in aa:
  if a%2==0 and (a%3!=0 and a%5!=0):
    print('DENIED')
    exit(0)
print('APPROVED')

C問題

collections.Counter()を用いることで、
要素の出現回数をディレクトリ型にしてくれます。

import collections
n = int(input())
words = []
[words.append(input()) for i in range(n)]
c = collections.Counter(words)
cc = c.most_common()
max_w = []
for i in cc:
  if i[1]==cc[0][1]:
    max_w.append(i[0])
max_w.sort()
[print(j) for j in max_w]

D問題

D問題以降は茶色コーダーになってから随時更新していきます。