Recently, I was a regular in the top 20%, but this time it was in the top 38.4%, so it was good to be unrated ....
It broke through in 4 minutes. I only wrote it, but it took me a long time because I couldn't see the problem sentence for more than 2 minutes from the beginning. You remember the formula of the length of the circumference, right?
from math import pi
R = int(input())
print(2 * pi * R)
Break through in one and a half minutes. Just write. Simply add up the number of days required for your homework and compare it with the number of days during the summer vacation.
N, M = map(int, input().split())
A = list(map(int, input().split()))
a = sum(A)
if a > N:
print(-1)
else:
print(N - a)
Postscript: This is good.
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(max(N - sum(A), -1))
It broke through in 7 and a half minutes. I made a list of direct subordinates in the dictionary, but now I realized that I'm doing too much in vain. It's easier to add the number of people to the list obediently ....
N = int(input())
A = list(map(int, input().split()))
d = {}
for i in range(N - 1):
if A[i] in d:
d[A[i]].append(i + 2)
else:
d[A[i]] = [i + 2]
for i in range(1, N + 1):
if i in d:
print(len(d[i]))
else:
print(0)
Postscript: This is good.
N = int(input())
A = list(map(int, input().split()))
result = [0] * N
for a in A:
result[a - 1] += 1
print('\n'.join(map(str, result)))
ABC163D - Sum of Large Numbers
Rainy day defeat. 0 was too disturbing.
Postscript: Why did I worry about the combination calculation and 0 being a hindrance and duplication? It's really too stupid and I'm in trouble.
N, K = map(int, input().split())
result = 0
for i in range(K, N + 2):
# max: N, N -1, ..., N - i + 1
a = (N + (N - i + 1)) * i // 2
# min: 0, 1, .., i - 1
b = (0 + (i - 1)) * i // 2
result += a - b + 1
result %= 1000000007
print(result)
Recommended Posts