ABC195 - Atcoder/Python精進のための解説メモ
2022/12/27
ABC195 - A.Health M Death
AtCoder公式 | ABC195 - A.Health M Death解答
m, h = map(int, read().split())
print('Yes' if h % m == 0 else 'No')
要点解説メモ
- シンプルにあまりで分岐
ABC195 - B.Many Oranges
AtCoder公式 | ABC195 - B.Many Oranges解答
a, b, w = map(int, input().split())
w *= 10 ** 3
min_ans = 1e9
max_ans = 0
for i in range(1, 10 ** 6 + 1):
if a * i <= w <= b * i:
min_ans = min(min_ans, i)
max_ans = max(max_ans, i)
if max_ans == 0:
print('UNSATISFIABLE')
else:
print(min_ans, max_ans)
別解
a, b, w = map(int, input().split())
w *= 10 ** 3
lower = (w + b - 1) // b
upper = w // a
print(lower, upper if lower <= upper else 'UNSATISFIABLE')
要点解説メモ
- たかだか10**6通りなので全探索すればよい
- 最小値と最大値を計算しても出せる
ABC195 - C.Comma
AtCoder公式 | ABC195 - C.Comma解答
n = int(input())
ans = 0
if 10 ** 3 < n:
ans += n - 999
if 10 ** 6 < n:
ans += n - 999999
if 10 ** 9 < n:
ans += n - 999999999
if 10 ** 12 < n:
ans += n - 999999999999
if 10 ** 15 <= n:
ans += n - 999999999999999
print(ans)
要点解説メモ
- 各数字ごとにカンマの数を数えるのではなく、各カンマの数え方を考える
- 高校数学の、より簡単な変数で表せる値を見つけるやつ
ABC195 - D.
AtCoder公式 | ABC195 - D.解答
まだ解いていません