I wanted to solve the Panasonic Programming Contest 2020 with Python

Introduction

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.

A problem

Problem

** 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])

B problem

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))

C problem

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.

Summary

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

I wanted to solve the Panasonic Programming Contest 2020 with Python
I wanted to solve NOMURA Contest 2020 with Python
I wanted to solve ABC160 with Python
I wanted to solve ABC172 with Python
I wanted to solve the ABC164 A ~ D problem with Python
Try to solve the programming challenge book with python3
I tried to solve the soma cube with python
I tried to solve the problem with Python Vol.1
I wanted to solve ABC159 in Python
I tried to solve the ant book beginner's edition with python
Try to solve the man-machine chart with Python
I wanted to play with the Bezier curve
I wanted to install Python 3.4.3 with Homebrew + pyenv
I want to solve APG4b with Python (Chapter 2)
Try to solve the internship assignment problem with Python
I tried to touch the CSV file with Python
I wanted to use the Python library from MATLAB
I want to inherit to the back with python dataclass
I tried to solve AOJ's number theory with Python
I wanted to visualize 3D particle simulation with the Python visualization library Matplotlib.
I tried to find the entropy of the image with python
I tried to simulate how the infection spreads with Python
What I did to welcome the Python2 EOL with confidence
[Python] I want to use the -h option with argparse
I liked the tweet with python. ..
I captured the Touhou Project with Deep Learning ... I wanted to.
I tried to divide the file into folders with Python
I want to debug with Python
The 15th offline real-time I tried to solve the problem of how to write with python
How to write offline real time I tried to solve the problem of F02 with Python
atcoder Review of Panasonic Programming Contest 2020, up to question E (Python)
I want to know the weather with LINE bot feat.Heroku + Python
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
I want to output the beginning of the next month with Python
I tried to improve the efficiency of daily work with Python
Try to solve the shortest path with Python + NetworkX + social data
I want to analyze logs with Python
I want to play with aws with python
I tried to solve TSP with QAOA
I really wanted to copy with selenium
The road to compiling to Python 3 with Thrift
I tried to solve the first question of the University of Tokyo 2019 math entrance exam with python sympy
What skills do I need to program with the FBX SDK Python?
How to write offline real time I tried to solve E11 with python
The 16th offline real-time how to write reference problem to solve with Python
I tried to get the authentication code of Qiita API with Python.
It's more recent, but I wanted to do BMI calculation with python.
I tried with the top 100 PyPI packages> I tried to graph the packages installed on Python
I tried to streamline the standard role of new employees with Python
The 19th offline real-time how to write reference problem to solve with Python
I tried to get the movie information of TMDb API with Python
How to write offline real time I tried to solve E12 with python
Try to solve the fizzbuzz problem with Keras
I tried "smoothing" the image with Python + OpenCV
I made a competitive programming glossary with Python
How to enjoy programming with Minecraft (Ruby, Python)
I want to use MATLAB feval with python
Try to solve the Python class inheritance problem
I tried "differentiating" the image with Python + OpenCV
I tried to save the data with discord
The easiest way to synthesize speech with python