ABC156 - Atcoder/Python精進のための解説メモ
2022/12/27
ABC156 - A.Beginner
AtCoder公式 | ABC156 - A.Beginner解答
n, k = map(int, input().split())
if n < 10:
print(k + (100 * (10 - n)))
else:
print(k)
要点解説メモ
- 計算する
ABC156 - B.Digits
AtCoder公式 | ABC156 - B.Digits解答
import math
n, k = map(int, input().split())
print(int(math.log(n, k) + 1))
要点解説メモ
- logする
ABC156 - C.Rally
AtCoder公式 | ABC156 - C.Rally解答
n = int(input())
xxx = list(map(int, input().split()))
ans = 1e7
for i in range(min(xxx), max(xxx) + 1):
tmp_xxx = tuple(map(lambda x: (x - i) ** 2, xxx))
ans = min(ans, sum(tmp_xxx))
print(ans)
要点解説メモ
- 最小のxから最大のxの間に、総和を最小にする地点があるので全探索
- 全体の平均を出して付近の整数値をとればO(3)くらいでもいけそう
- 探索したほうが安全感ある
ABC156 - D.
AtCoder公式 | ABC156 - D.解答
まだ解いていません