ABC168

We participated in AtCorder Beginner Contest 168. It was ABC's 3 questions AC. I'm using Python3.

A problem

Take out the rightmost number and divide it into cases.

N = input()
if N[-1] == '3':
    print('bon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
    print('pon')
else:
    print('hon') 

B problem

It is divided into cases according to the length of the character string, and if it is short, it is output as it is, and if it is long, it is omitted.

K = int(input())
S = input()
if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')

C problem

Find the minute speed of the long hand and the short hand, and find the angle (difference from the top) at H hours and M minutes. This gives the two sides and the angle between them, so the length of the other side is found by the cosine theorem.

import math
A, B, H, M = map(int,input().split())
T = 60 * H + M
a = (360 /60/ 12) * T
b = ((360 / 60) * T ) % 360
k = abs(a - b)
print(a, b, k)
if k > 180:
    kakudo = 360 - k
else:
    kakudo = k
X = A ** 2 + B **2 - 2 * A * B * math.cos(math.radians(kakudo)) #Cosine theorem
print(X ** (1/2))

Recommended Posts

ABC168
ABC164
ABC174
ABC175
ABC170
ABC182
ABC153
ABC146 Impressions
AtCoder ABC176
ABC167 WriteUp
AtCoder ABC177
Beginner ABC154 (Python)
Beginner ABC156 (Python)
abc154 participation report
abc155 participation report
AtCoder ABC 174 Python
AtCoder ABC187 Python
AtCoder ABC188 Python
Beginner ABC155 (Python)
Beginner ABC157 (Python)
AtCoder ABC 175 Python
Looking back on ABC155
Atcoder ABC115 Past Exercises
Solve ABC169 in Python
ABC147 C --HonestOrUnkind2 [Python]