Break through in 5 minutes. Just write. It took a long time because the problem statement was not displayed in the middle.
K, X = map(int, input().split())
if 500 * K >= X:
print('Yes')
else:
print('No')
Break through in two and a half minutes. Just write.
N = int(input())
S = input()
result = 0
for i in range(N):
if S[i:i+3] == 'ABC':
result += 1
print(result)
It broke through in 26 minutes. It was difficult for a C problem, or I didn't feel like I could solve it at first. I wish I had just added up honestly ...
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
fac = [0] * 8
fac[1] = 1
for i in range(2, N):
fac[i] = i * fac[i - 1]
a = 0
l = list(range(1, N + 1))
for i in range(N):
a += l.index(P[i]) * fac[len(l) - 1]
l.remove(P[i])
b = 0
l = list(range(1, N + 1))
for i in range(N):
b += l.index(Q[i]) * fac[len(l) - 1]
l.remove(Q[i])
print(abs(a - b))
ABC150D - Semi Common Multiple
Defeated.
Postscript: I wrote it according to the explanation in PDF.
from fractions import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
a = A[0]
n = 1
while a % 2 == 0:
n *= 2
a //= 2
lcm = 1
for a in A:
if a % n != 0 or a % (2 * n) == 0:
print(0)
exit()
lcm = lcm * a // gcd(lcm, a)
if lcm // 2 > M:
print(0)
exit()
print((M - lcm // 2) // lcm + 1)
Recommended Posts