![見出し画像](https://assets.st-note.com/production/uploads/images/92537164/rectangle_large_type_2_bdbaa2daf3fbd67ca3bbdc836da8d001.png?width=1200)
atcoder(python解き方)
問題①
![](https://assets.st-note.com/img/1670074380166-w5Q44w7AKY.png?width=1200)
![](https://assets.st-note.com/img/1670074428002-UmnEI8cCi1.png?width=1200)
解答コード
def sample1():
"""A問題"""
h, w = map(int, input().split())
ans_lst = [input() for _ in range(h)]
ans = [0]
for i in ans_lst:
for j in i:
if j == '#':
ans[0] += 1
print(*ans)
問題②
![](https://assets.st-note.com/img/1670074536848-EZKki3fx8B.png?width=1200)
![](https://assets.st-note.com/img/1670074579325-uw2Ag9nU5B.png?width=1200)
解答コード
def sample2():
"""B問題"""
n = int(input())
n_lst = list(map(int, input().split()))
ans = []
cnt = 0
for i in n_lst:
if cnt == 0:
ans.append(i)
cnt += 1
continue
ans_1 = i - n_lst[cnt - 1]
cnt += 1
ans.append(ans_1)
print(*ans)
問題③
![](https://assets.st-note.com/img/1670074681636-6qVVnoVWIc.png?width=1200)
![](https://assets.st-note.com/img/1670074718152-mqaYTK9MY4.png?width=1200)
解答コード
def sample3():
"""C問題"""
S = input()
T = input()
cnt = 1
for i in range(len(S)):
if S[i] != T[i]:
break
else:
cnt += 1
print(cnt)
以上になります。
この記事が参加している募集
この記事が気に入ったらサポートをしてみませんか?