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?

問題概要

チーム高橋とチーム青木の試合数と勝った回数が与えられる。
勝率の高いチームを出力せよ。

解法と実装

小数点の計算は誤差によってWAとなることが多いので、なるべく整数で計算することを考えます。
$a$試合中$b$回勝った時の勝率は、$a\times c$試合中$b\times c$回勝った時の勝率と同じです。
チーム青木についても同様に考えることで、それぞれ$a\times c$試合のうち、チーム高橋は$b\times c$回、チーム青木は$a\times d$回勝った時の勝率を比較すれば良いことになります。

a, b, c, d = map(int, input().split()) # 入力を受け取り
if b*c == a*d: # それぞれの勝率が同じ時
  print("DRAW")
elif b*c > a*d:
  print("TAKAHASHI")
else:
  print("AOKI")
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?