AtCoder Beginner Contest 295の解説記事です。
目次
ABC295 A – Probably English
問題
問題文の要約は以下の通りです。
問題の要約
N 個の文字列 W1 , W2 , … , WN のいずれかがand, not, that, the, youと一致するか判定せよ。
入力
N
W1 W2 … WN
出力
いずれかと一致するなら Yes 、そうでないなら No と出力せよ。
解法
W[i]とand, not, that, the, youが一致するか判定する。
解説
W[i]とand, not, that, the, youが一致するか判定します。
if W[i] == 'and' or W[i] == 'not' or W[i] == 'that' or W[i] == 'the' or W[i] == 'you':一致したらYesを出力、処理を終了します。W[N]まで一致しなければNoを出力します。
解答
N=int(input())
W=list(map(str,input().split()))
for i in range(N):
if W[i] == 'and' or W[i] == 'not' or W[i] == 'that' or W[i] == 'the' or W[i] == 'you':
print('Yes')
return 0
print('No')
