ABC168 - Atcoder/Python精進のための解説メモ
2022/12/27
ABC168 - A.∴ (Therefore)
AtCoder公式 | ABC168 - A.∴ (Therefore)解答
n = int(input()[-1])
if n == 3:
ans = 'bon'
elif n in [0, 1, 6, 8]:
ans = 'pon'
else:
ans = 'hon'
print(ans)
要点解説メモ
- str型とint型の扱いに注意したいところ
ABC168 - B.... (Triple Dots)
AtCoder公式 | ABC168 - B.... (Triple Dots)解答
k = int(input())
s = input()
if k < len(s):
s = s[:k] + '...'
print(s)
要点解説メモ
- pythonはスライス力が大事
ABC168 - C.: (Colon)
AtCoder公式 | ABC168 - C.: (Colon)解答
import math
a, b, h, m = map(int, input().split())
theta_l = m / 60 * 360
theta_s = h * 30 + m / 60 * 30
theta_c = abs(theta_l - theta_s)
cos_c = math.cos(math.radians(theta_c))
print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cos_c))
要点解説メモ
- 余弦定理だ!って感じの問題
- 座標計算でもいけるみたい
ABC168 - D.
AtCoder公式 | ABC168 - D.解答
まだ解いていません