Break through in 4 minutes. Just write.
N, R = map(int, input().split())
if N >= 10:
print(R)
else:
print(R - 100 * (10 - N))
Break through in 2 minutes. Just write. If you know that the K-ary 10 is K and 100 is K 2 </ sup>, you just need to find out how many times you can divide by K.
N, K = map(int, input().split())
result = 0
while N != 0:
result += 1
N //= K
print(result)
Break through in 3 and a half minutes. Just write ... because I'm used to this calculation. (X i </ sub> −P) 2 </ sup> is the minimum P Center of gravity. I am doing this 3D calculation with color-reduced K-means …….
N = int(input())
X = list(map(int, input().split()))
P = int(sum(X) / N + 0.5)
print(sum((x - P) * (x - P) for x in X))
Break through in 70 and a half minutes. First, n </ sub> C 0 </ sub> + n </ sub> C 1 </ sub> + ... + You have to know n </ sub> C n </ sub> = 2 n </ sup>. I didn't know orz. Pascal's Triangle Wikipedia I found out that this is the end of pasting the mcomb I wrote in the past, but there is a part that asks for n !, and it is killed by 2 ≤ n ≤ 10 9 </ sup>. A, b are at most 10 I noticed that it was 5 </ sup>, and finally solved it by rearranging it into another formula that finds n </ sub> C k </ sub>. Good question!
def mcomb(n, k):
a = 1
b = 1
for i in range(k):
a *= n - i
a %= 1000000007
b *= i + 1
b %= 1000000007
return a * pow(b, 1000000005, 1000000007) % 1000000007
n, a, b = map(int, input().split())
result = pow(2, n, 1000000007) - 1
result -= mcomb(n, a)
result + 1000000007
result %= 1000000007
result -= mcomb(n, b)
result + 1000000007
result %= 1000000007
print(result)
Recommended Posts