0
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?

問題概要

3つの課題の配点sと評価eが与えられる。
合計得点を求めよ。

解法と実装

入力が3回なので、それぞれ入力と答えの更新を書いて答えを求めることができます。

ans = 0 # 答えの初期値は0

s1, e1 = map(int, input().split())
ans += (s1 * e1) // 10 # 答えは整数値なので//

s2, e2 = map(int, input().split())
ans += (s2 * e2) // 10

s3, e3 = map(int, input().split())
ans += (s3 * e3) // 10

print(ans)

for文を使ってまとめて入力を受け取ることがで、簡潔に書くことができます。

ans = 0
for i in range(3): # 入力が3回なのでfor文を使うことで、入力と答えの更新をまとめられる
  s, e = map(int, input().split())
  ans += (s * e) // 10
print(ans)

備考

浮動小数点によって値が変わることがあるので、値の更新は整数値を取る計算を先に行うようにしています。

0
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
0
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?