I forgot and couldn't participate, so I'll solve it. I solved it with midnight tension + I wrote it at midnight, so the sentence may have collapsed.
** Thoughts ** Just count A and B in S. Only when all are A and B, No should be set. .. I counted it with str.count and put it in if.
s = str(input())
station_a = s.count('A')
station_b = s.count('B')
if station_a != 3 and station_b != 3:
print('Yes')
else:
print('No')
Way of thinking Just count how many A + B pairs there are in N. The number of pairs of $ A + B * A $ alone does not include the remainder. So calculate the remainder with $ N% (A + B) $ and add it. If you think about it, the remainder may be larger than A, so add min (a, (n% (a + b))).
n, a, b =map(int,input().split())
p = n // (a + b)
ans = a * p + min(a,(n % (a + b)))
print(ans)
Problem 1WA ** Thoughts ** I calculated it normally. The reason why 1WA came out is that the stop of the for statement was set to 1000 instead of 1001. Because of this, one of them couldn't handle the case where the answer was 1000. Everyone should be careful about stop for for.
import math
a, b = map(int,input().split())
ans = []
for i in range(1010): #I made 1000 here
price_8 = math.floor(i * 0.08)
price_10 = math.floor(i * 0.1)
if price_8 == a and price_10 == b:
ans.append(i)
if len(ans) != 0:
print(min(ans))
else:
print(-1)
It turns out that a simple ABC can be solved even at midnight. good night
Recommended Posts