I usually participate in the contest → I end up reviewing it, but I wanted to keep a record of my thoughts during the contest, so I decided to write an article. (I don't know how long it will last)
I implemented it honestly.
A.py
S = input()
if S == "SUN":
print(7)
elif S == "MON":
print(6)
elif S == "TUE":
print(5)
elif S == "WED":
print(4)
elif S == "THU":
print(3)
elif S == "FRI":
print(2)
else:
print(1)
I didn't know how to convert characters to ASCII code, so
I asked Google teacher and found out ʻord () and
chr () `.
Express the target character as 0 to 25
, add N to shift it N times, and divide by 26 to find the remainder.
Finally, add ʻord ("A") `to revert to the ASCII code in the uppercase alphabet.
The answer was found by doing this for each character.
B.py
N = int(input())
S = input()
new_s = []
for c in S:
new_s.append(chr((ord(c) - ord("A") + N) % 26 + ord("A")))
print("".join(new_s))
At first I did a full search for N, but it was TLE. (That's right) I thought that PyPy would pass (?), And I repeated TLE. On the way, I realized that a binary search can be used to find the "maximum value among the conditions". I was able to pass it.
It is regrettable that I stuck to one method too much and took 30 minutes to reach the binary search.
C.py
a,b,x = map(int, input().split())
left = 0
right = 10**9 + 1
while right > left + 1:
n = (left + right) // 2
if a * n + b * len(str(n)) <= x:
left = n
else:
right = n
print(left)
It was totally useless. The graph problem gets a rejection reaction the moment I see it, so I want to study hard somewhere, but I haven't touched it ...
Do you have any good learning materials? ??
I want to turn green soon!
Recommended Posts