I feel like saying it every time, but it's been a long time. Succeeded in preventing 4 consecutive colds.
Rainy Season 1WA
** Thoughts ** Counts how many Rs are in a row.
s = input()
if 'RRR' in s:
print(3)
elif 'RR' in s:
print(2)
elif 'R' in s:
print(1)
else:
print(0)
Since the if statement is processed from the top, it will be processed in order, so be careful of the order. I was WA with this.
Making Triangle ** Thoughts ** I just did the existence condition of the triangle, but it took time to misread the problem sentence. Search all for small $ N $.
n = int(input())
n = int(input())
l = list(map(int,input().split()))
ans = 0
for i in range(n):
for j in range(i,n):
for k in range(j,n):
if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
continue
else:
ver = [l[i],l[j],l[k]] #3 side length
ver.sort()
if ver[0] + ver[1] > ver[2]:
ans += 1
print(ans)
Walking Takahashi ** Thoughts **
-If $ X $ is positive and $ X-K * D $ is also positive, then $ X-K * D $ has the closest absolute value.
-Similarly
――Imagine a case where neither of the above is true. Let $ dis $ be the smallest positive number that can be moved within $ K $ times, and $ dis'$ be the smallest negative number that can be reached within $ K $ times. If you arrive at $ dis $ at the $ T (T \ leq K) $ th time, --If T is an even number, then $ dis → dis'→ \ dots dis $ --If T is odd, then $ dis → dis'→ \ dots dis'$
x, k, d = map(int,input().split())
if x - k * d >= 0:
print(x - k * d)
elif x + k * d <= 0:
print(abs(x + k * d))
else:
dis = x % d
dis_p = d - dis
t = k - x // d
if t % 2 == 0:
print(dis)
else:
print(dis_p)
The guideline of D was correct, but it was moss in the implementation. See you again, good night.
Recommended Posts