This time I could only solve A and B. It is not good that only A and B can be solved in the ABC equivalent contest.
** Thoughts ** I copied the sequence written in the problem and printed it by specifying the index with k.
k = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])
Problem 1WA ** Thoughts ** Looking at the figure of the problem statement, I thought that adding the i-th line and the i + 1-th line would give W, so I tried to calculate by the evenness of h, but I did 1WA. The reason for WA is that it did not consider when W and H were 1. Therefore, I wrote the case where either one is 1.
import math
h, w = map(int,input().split())
if w == 1 or h == 1:
print(1)
quit()
if h % 2 != 0:
ans = w * (h-1) / 2 + math.ceil(w / 2)
print(int(ans))
else:
ans = w * h / 2
print(int(ans))
Problem 12WA NoAC
** Thoughts ** I saw hell when I thought it was a math problem. First of all, I put everything in sqrt and calculated it with 1WA, so I thought that I had to reduce the calculation well. Therefore, I prepared a piece of paper and a pen and desperately calculated with mathematical power close to zero.
\sqrt(a) + \sqrt(b) < \sqrt(c)Since both sides are 0 or more, square both sides\\
= a + b < c
= a + b - c + 2\sqrt(ab)<If 0 holds\sqrt(a) + \sqrt(b) < \sqrt(c)Meet\\
a + b -Since c is an integer, I thought it wouldn't overflow computationally, so\\
2\sqrt(ab)I thought about how to handle it.\\
From the relationship of additive geometric mean\\
a + b >= 2 \sqrt(ab) \\
Is established. The condition for establishing an equal sign is a=Since it is b, I thought that it should be divided by if at that time.\\
The problem is a!=At the time of b, I couldn't erase the radical by myself.\\
So I thought I'd devised it well, but WA didn't disappear ... I couldn't AC after all. When I looked at the code of other AC people after the contest was over, I found that they used a module called Decimal to calculate decimals well. If I could calculate it so easily, it would have been an easy win problem ...
from decimal import *
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
print("Yes")
else:
print("No")
It was AC.
It was a contest to reaffirm the lack of knowledge about language. I'm sad and regrettable. I have an AtCoder challenge every day, so I want to get results in the next contest. So, good night.
Recommended Posts