Kajima Construction Programming Contest 2020 (AtCoder Regular Contest 110) - AtCoder
A
- Multiplying all of them by +1 satisfies the remainder condition, but it is too large, so I found least common denominator.
- Related: Chinese remainder theorem. python
from math import gcd
N = int(input())
x = 1
for i in range(2, N + 1):
g = gcd(x, i)
x *= i // g
print(x + 1)
B
- In short, whether this automaton accepts or not.
- There is a trap when the input is a single character, so it is only the case there. python
def solve(N, T):
if N == 1:
if T == "1":
return 2 * 10 ** 10
elif T == "0":
return 10 ** 10
state = [True, True, True]
for c in T:
nextState = [0] * 3
for i in range(3):
nextState[i] = state[i - 1] and (c == "011"[i])
state = nextState
ret = 0
for i in range(3):
if state[i]:
ret += (3 * 10 ** 10 - ((i - N) % 3 + N)) // 3 + 1
return ret
ARC110C ARC110D
This page is auto-translated from /nishio/ARC110 using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.