Beginner ABC156 (Python)

Click here for the contest page

https://atcoder.jp/contests/abc156 A

n,r = map(int, input().split())
ans = r
if n < 10: ans = r + 100 * (10 - n)
print(ans)

Recalculate the internal rate only if n is less than 10.
Submission https://atcoder.jp/contests/abc156/submissions/10269586

B

n,k = map(int, input().split())

def base(a, b):
  if (int(a/b)): return base(int(a/b), b) + str(a % b)
  return str(a % b)

ans = base(n, k)
print(len(ans))

To convert the decimal digit ʻato ab` base -** divide a by b ** -** Arrange the remainder from the first digit ** There is a method of repeating these two ** until the quotient of ** a ÷ b becomes 0 (stops when it becomes 0). (During the contest, I checked the calculation method and imitated it.)
Submission https://atcoder.jp/contests/abc156/submissions/10274589

C

n = int(input())
*x, = map(int, input().split())
ans = float('inf')
for i in range(min(x), max(x)+1):
    tmp = 0
    for j in x:
        tmp += (j - i)*(j - i)
    ans = min(ans, tmp)
print(ans)

~~ Sort the coordinates of the inhabitants in ascending order, ~~ In the range from the minimum to the maximum, when each coordinate is used as the place to hold the rally (ʻi for statement), The total physical strength consumed by each resident was calculated (j`for statement) and the minimum value was considered. Since N is small, it's okay to check everything (I noticed on the way).
Submission https://atcoder.jp/contests/abc156/submissions/10326967 ~~https://atcoder.jp/contests/abc156/submissions/10281863~~

** Additions / corrections ** We received comments from @ c-yan and corrected the unnecessary sort parts.

D, E and F

I would like to add it if I can AC.

Recommended Posts

Beginner ABC154 (Python)
Beginner ABC156 (Python)
Beginner ABC155 (Python)
Beginner ABC157 (Python)
python beginner memo (9.2-10)
AtCoder ABC 174 Python
python beginner memo (9.1)
Python beginner notes
[Beginner] Python array
AtCoder ABC187 Python
AtCoder ABC188 Python
[Beginner] Python functions
PyQ ~ Python Beginner ~
Python beginner memo (2)
AtCoder ABC 175 Python
Python beginner Zundokokiyoshi
Python beginner Atcoder memo @ KEYENCE 2020, ABC problem
Solve ABC169 in Python
ABC147 C --HonestOrUnkind2 [Python]
AtCoder ABC 177 Python (A ~ E)
ABC168
Solve AtCoder ABC166 with python
ABC164
ABC163 C problem with python3
python super beginner tries scraping
AtCoder ABC 178 Python (A ~ E)
Python
Atcoder ABC164 A-C in Python
Solve ABC176 E in Python
ABC memorandum [ABC163 C --managementr] (Python)
Python beginner launches Discord Bot
ABC174
AtCoder ABC 176 Python (A ~ E)
Atcoder ABC167 A-D in Python
Solve ABC175 D in Python
Atcoder ABC165 A-D in Python
Atcoder ABC166 A-E in Python
ABC175
ABC170
AtCoder ABC 182 Python (A ~ D)
Web scraping beginner with python
ABC188 C problem with python3
[Python beginner] Update pip itself
Solve AtCoder ABC 186 with Python
Atcoder Beginner Contest 152 Kiroku (python)
ABC182
ABC153
ABC187 C problem with python
Atcoder ABC169 A-E in Python
AtCoder ABC177 A-D in python
ABC memorandum [ABC159 C --Maximum Volume] (Python)
Solve ABC163 A ~ C with Python
ABC127 A, B, C Explanation (python)
Solve ABC166 A ~ D with Python
ABC166 in Python A ~ C problem
Solve Atcoder ABC169 A-D in Python
Let's play with Excel with Python [Beginner]
[Python beginner] Divide one list (5 lines).
Solve ABC168 A ~ C with Python
ABC memorandum [ABC161 C --Replacing Integer] (Python)
Solve ABC036 A ~ C in Python