Break through in one and a half minutes. I used xor, but the title was Not (laughs).
x = int(input())
print(x ^ 1)
Break through in 2 minutes. One of the ends should be the maximum.
a, b, c, d = map(int, input().split())
print(max(a * c, a * d, b * c, b * d))
Break through in 5 minutes. Subtract the number of combinations that do not contain 0 and the number of combinations that do not contain 9 from the number of all combinations, and then the number of combinations that do not contain both 0 and 9 is doubled. The answer is what I added back.
m = 1000000007
N = int(input())
print((pow(10, N, m) - pow(9, N, m) * 2 + pow(8, N, m)) % m)
Break through in 29 minutes. When the length of the sequence is n, when S-3 × n is distributed to n, if you are groaning about the number of divisions, you think that you will insert a partition bar ABC132D --Blue and Red Balls I solved it. The number of cases to allow duplication from n types and select r is n </ sub> > H r </ sub> = n + r−1 </ sub> C r </ sub> street.
def make_factorial_table(n):
result = [0] * (n + 1)
result[0] = 1
for i in range(1, n + 1):
result[i] = result[i - 1] * i % m
return result
def mcomb(n, k):
if n == 0 and k == 0:
return 1
if n < k or k < 0:
return 0
return fac[n] * pow(fac[n - k], m - 2, m) * pow(fac[k], m - 2, m) % m
m = 1000000007
S = int(input())
fac = make_factorial_table(S + 10)
result = 0
for i in range(1, S // 3 + 1):
result += mcomb(S - i * 3 + i - 1, i - 1)
result %= m
print(result)
I couldn't break through. I was confident that this problem was solved so much, and when I googled at "Maximum Manhattan Distance", it came out after all orz.
Recommended Posts