AtCoder ABC180 This is a summary of the AtCoder Beginner Contest 180 problems that took place on 2020-10-17 (Sat), starting with problem A and taking into account the considerations. The problem is quoted, but please check the contest page for details. Click here for the contest page Official commentary PDF

Problem statement I took out $ A $ balls from the box that contained $ N $ balls and put in new $ B $ balls. How many balls are in the box now?

`abc180a.py`

```
n, a, b = map(int, input().split())
print(n - a + b)
```

Problem statement $ N $ A point $ (x_1,…, x_N) $ in dimensional space is given. Find the Manhattan distance, Euclidean distance, and Chebyshev distance from the origin to this point, respectively. However, each distance is calculated as follows: ・ Manhattan distance:

|x_1|+…+|x_N| ・ Euclidean distance:\sqrt{|x_1|^2+…+|x_N|^2} Chebyshev Distance:max(|x_1|,…,|x_N|)

`abc180b.py`

```
n = int(input())
x_list = list(map(int, input().split()))
a = 0
b = 0
c = 0
for x in x_list:
if x < 0:
x *= -1
a += x
b += x * x
if c < x:
c = x
print(a)
print(b**(0.5))
print(c)
```

Problem statement There are $ N $ cream puffs. Find all possible numbers of people who can divide the cream puffs equally without dividing them.

`abc180c.py`

```
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5)+1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n//i)
divisors.sort()
return divisors
n = int(input())
for x in make_divisors(n):
print(x)
```

Problem statement Iroha is addicted to pet raising games. Iroha has Takahashi as a pet, and Takahashi's strength is $ X $ and his experience is $ 0 $. These values will be increased by the following $ 2 $ types of special training. ・ Go to Cacommon Gym: Strength is doubled by $ A $ and experience is increased by $ 1 $. ・ Go to the AtCoder gym: Strength increases by $ B $ and experience points increase by $ 1 $. Takahashi evolves when the strength is over $ Y $, but Iroha thinks that it is cute if it does not evolve. Therefore, when imposing special training on Mr. Takahashi so that the strength does not exceed $ Y $, please find the maximum value of experience points.

During the contest, I used log to calculate how many times I could go to Cacommon Gym so as not to use iterative processing.
(` n = int (math.log (b / a / x, a)) + 1`

feeling)
Looking at the explanation, I read that the number of times I can go to Cacommon Gym is limited to less than $ 64 $, and I thought it was true.
The code is from the commentary.

`abc180d.py`

```
x,y,a,b=map(int,input().split())
ans=0
while a*x<=x+b and a*x<y:
x*=a
ans+=1
print(ans+(y-1-x)//b)
```

Recently, even if I can solve the D problem, I have spent too much time on some problem up to that point and have not been able to solve the E problem, so I would like to be able to solve the problem a little more flexibly.

Thank you for reading until the end.

Recommended Posts