Only A and B can be solved. I have no choice but to solve the problem in a straightforward manner while being appalled by my unsolvableness. This time it was a math session (?).

https://atcoder.jp/contests/abc178

A. Not

```
x = int(input())
if x == 0:
print(1)
else:
print(0)
```

I think there are various ways to write it, but I honestly wrote it in an if statement.

B. Product Max

```
a, b, c, d = map(int, input().split())
answer = 0
if a < 0 and 0 <= b:
if c < 0 and 0 <= d:
answer = max(a * c, b * d)
elif 0 <= c and 0 <= d:
answer = b * d
elif c < 0 and d < 0:
answer = a * c
elif 0 <= a and 0 <= b:
if c < 0 and 0 <= d:
answer = b * d
elif 0 <= c and 0 <= d:
answer = b * d
elif c < 0 and d < 0:
answer = a * d
elif a < 0 and b < 0:
if c < 0 and 0 <= d:
answer = a * c
elif 0 <= c and 0 <= d:
answer = b * c
elif c < 0 and d < 0:
answer = a * c
print(answer)
```

In the middle of writing the if statement, I thought "I can do it with max ...", but I wrote all the cases without turning back. Even if you don't divide it like this, you can solve it with max as shown below.

```
a, b, c, d = map(int, input().split())
answer = max(a*c, a*d, b*c, b*d)
print(answer)
```

C. Ubiquity

```
MOD = 10**9 + 7
N = int(input())
#At least 0 is included
in0 = 10**N - 9**N
#At least 0 is included
in9 = 10**N - 9**Nu
#There is 0 or 9
0and9 = 10**N - 8**N
answer = in0 + in9 - 0and9
print(answer%MOD)
```

I had an answer to my throat, but for some reason I couldn't come up with an answer. Since it cannot be counted normally, it is calculated by subtracting from the whole. The image below.

D. Redistribution

```
MOD = 10**9 + 7
S = int(input())
dp = [0] * (S+1)
dp[0] = 1
for i in range(1, S+1):
for j in range(0, (i-3)+1):
dp[i] += dp[j]
dp[i] %= MOD
print(dp[S])
```

Answer by snuke As it is.

`dp`

I only know what I knew.
If you look at the explanation, you can see that it is "certainly", but when you are actually told to solve it within the time limit, you cannot solve `` `DP```.
Not enough training ...

E. Dist Max

```
N = int(input())
a, b = [], []
for i in range(N):
x, y = map(int, input().split())
a.append(x+y)
b.append(x-y)
a.sort()
b.sort()
answer = max(a[-1] - a[0], b[-1] - b[0])
print(answer)
```

This is also snuke's answer as it is.

I learned how to transform the formula of max.

Recommended Posts