I would like to write a commentary on ABC's A, B, and C problems in Reiwa, hoping that it will be a training to deepen one's understanding and a little help for someone.
https://atcoder.jp/contests/abc126/tasks/abc126_a
Can it be connected with lower use?
n,k = map(int,input().split())
s = input()
print(s[:k-1]+s[k-1].lower()+s[k:])
Output up to the character before k with s [: k-1] Output with s [k-1] .lower () in lowercase k Output k and later with s [k:]
https://atcoder.jp/contests/abc126/tasks/abc126_b
Judgment is made by looking at the two digits in the latter half of the first two digits. Therefore, at first, the data is received as str type. Convert the 1st, 2nd, 3rd and 4th characters together to int type.
s = input()
a = int(s[:2])
b = int(s[2:])
if 1 <= a and a <= 12 and 1<= b and b <=12:
print("AMBIGUOUS")
elif 1 <= a <=12 and (12 < b or b < 1):
print("MMYY")
elif (12 < a or a < 1) and 1 <= b <= 12:
print("YYMM")
else:
print("NA")
https://atcoder.jp/contests/abc126/tasks/abc126_c
I think it means to honestly implement the output method in output example 1. I managed to implement it by looking at the submission results of other people. .. ..
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
j = 0
if i < k:
while i*(2**j) < k:
j += 1
ans += (1/n)*1/(2**j)
else:
ans += (1/n)
print(ans)
Recommended Posts