ABC109 - Atcoder/Python精進のための解説メモ
2022/12/27
ABC109 - A.ABC333
AtCoder公式 | ABC109 - A.ABC333解答
a, b = map(int, input().split())
c = 3
print('Yes' if a * b * c % 2 == 1 else 'No')
要点解説メモ
- 条件は実はc=3の時しか成り立たない
ABC109 - B.Shiritori
AtCoder公式 | ABC109 - B.Shiritori解答
n = int(input())
www = [input() for _ in range(n)]
ans = 'Yes'
if len(list(set(www))) != n:
ans = 'No'
else:
for i in range(1, n):
if www[i][0] != www[i - 1][-1]:
ans = 'No'
print(ans)
要点解説メモ
- 1項目もしくは、n-1項までの範囲でまわすことに注意
ABC109 - C.Skip
AtCoder公式 | ABC109 - C.Skip解答
def gcd(x, y):
if y == 0:
return x
else:
return gcd(y, x % y)
n, x = map(int, input().split())
xxx = list(map(lambda xn: abs(int(xn) - x), input().split()))
ans = xxx[0]
for i in range(1, n):
ans = gcd(ans, xxx[i])
print(ans)
要点解説メモ
- 考察からxnからxを引いた数たちの最大公約数が、答えになることに気づきたい
- ユークリッドの互除法で最大公約数を高速で出す関数は、ぱっと出せるようにする
ABC109 - D.
AtCoder公式 | ABC109 - D.解答
まだ解いていません