Break through in 2 minutes. Just write.
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if D2 == 1:
print(1)
else:
print(0)
It broke through in four and a half minutes. I didn't know what to do if it didn't become an integer, and I issued it properly, but it was AC.
N = int(input())
X = N / 1.08
if int(X) * 108 // 100 == N:
print(int(X))
elif int(X + 1) * 108 // 100 == N:
print(int(X + 1))
else:
print(':(')
Break through in 7 and a half minutes. WA1. I thought it was more difficult than the recent ABC C problem. It wasn't because it was difficult, it was just Chombo.
X = int(input())
dp = [0] * (X + 1 + 105)
dp[0] = 1
for i in range(X):
if dp[i] == 1:
for j in range(100, 106):
dp[i + j] = 1
print(dp[X])
It breaks through in 22 minutes and a half. Since there are 3 characters, there are only 1000 patterns at the maximum from 000 to 999, so I can afford to try all patterns, but if N ≤ 30000, it seems to be TLE, so if 4 or more of the same characters are consecutive, it will be 3 I compressed and searched. Since only 3 characters are used anyway, a sequence of 4 or more characters is meaningless.
N = int(input())
S = input()
t = [S[0]]
p = S[0]
r = 1
for i in range(1, N):
if S[i] == p:
r += 1
if r < 4:
t.append(S[i])
else:
r = 1
t.append(S[i])
T = ''.join(t)
result = 0
for i in range(10):
a = T.find(str(i))
if a == -1:
continue
for j in range(10):
b = T.find(str(j), a + 1)
if b == -1:
continue
for k in range(10):
if T.find(str(k), b + 1) != -1:
result += 1
print(result)
Addendum: I didn't need to compress it (^^; I thought there was an extreme test case where there was a continuation after a series of about 30,000 characters. Otherwise, it's not a D problem difficulty.
N = int(input())
S = input()
result = 0
for i in range(10):
a = S.find(str(i))
if a == -1:
continue
for j in range(10):
b = S.find(str(j), a + 1)
if b == -1:
continue
for k in range(10):
if S.find(str(k), b + 1) != -1:
result += 1
print(result)
Break through in 28 minutes. WA1. I didn't want to trust that A1 was 0. Just keep applying the possible patterns from the beginning. E Easy for problems.
N = int(input())
A = list(map(int, input().split()))
result = 1
t = [0, 0, 0]
for i in range(N):
a = A[i]
f = -1
k = 0
for j in range(3):
if t[j] == a:
k += 1
if f == -1:
t[j] += 1
f = j
result = (result * k) % 1000000007
print(result)
I couldn't break through. But it's very easy as an F problem. I was disappointed that I missed it even though I seemed to be able to complete it for the first time.
from sys import exit
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
if A1 > B1:
A1, B1 = B1, A1
A2, B2 = B2, A2
if A2 < B2:
print(0)
exit()
if A1 * T1 + A2 * T2 < B1 * T1 + B2 * T2:
print(0)
exit()
if A1 * T1 + A2 * T2 == B1 * T1 + B2 * T2:
print('infinity')
exit()
a = B1 * T1 - A1 * T1
b = (A1 * T1 + A2 * T2) - (B1 * T1 + B2 * T2)
t = a // b
if a % b == 0:
print(t * 2)
else:
print(t * 2 + 1)
Recommended Posts