1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

PythonでABC168のA~Cを解く

Last updated at Posted at 2020-05-17

はじめに

大事故です。

A問題

問題

考えたこと
やるだけ

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問題

問題

考えたこと
やるだけ

k = int(input())
s = input()
n = len(s)

if n <= k:
    print(s)
else:
    print(s[:k]+"...")

C問題

問題

考えたこと
時針と分針の角度を計算して余弦定理。←cosの対称性を勘違いして6WA()。cosの値は$\frac{\pi}{2}$に対して対称じゃないですよ?なにを考えてるんですか? 受験生なのに受験数学できない

import math
a, b, h, m = map(int,input().split())

a_s = (30 * h) % 360 + 0.5 * m
b_s = (6*m)

s = max(a_s,b_s) - min(a_s,b_s)
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(s)))
print(ans)

D問題

1から近い順に見ていって、それぞれの親ノード(1に近い方)の番号をつければ解けそう。BFSとか?

まとめ

私は雑魚です。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?