結果

問題 No.9014 テストの合計点と平均点
ユーザー qwewe
提出日時 2025-05-14 13:09:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,606 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 54,320 KB
最終ジャッジ日時 2025-05-14 13:10:23
合計ジャッジ時間 1,033 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

# Read the input line containing the scores
line = input()

# Split the line by the comma and convert each part to an integer
try:
    j_str, m_str, b_str = line.split(',')
    j = int(j_str)
    m = int(m_str)
    b = int(b_str)

    # Validate input constraints (optional but good practice)
    if not (0 <= j <= 100 and 0 <= m <= 100 and 0 <= b <= 100):
        # Handle invalid input range if necessary, though problem statement implies valid input
        # For this problem, we can assume valid input based on constraints.
        pass 
        
    # Calculate the total score (T)
    T = j + m + b

    # Calculate the average score (A)
    # Use floating-point division
    average_precise = T / 3.0

    # Truncate (round down) the average to one decimal place
    # Multiply by 10, take the integer part (floor), then divide by 10.0
    # The int() conversion effectively floors the result for positive numbers.
    A_truncated = int(average_precise * 10) / 10.0

    # Format the output string
    # Use an f-string for easy formatting.
    # Use :.1f format specifier to ensure one decimal place is always shown, even if it's .0
    output_string = f"合計点:{T}平均点:{A_truncated:.1f}"

    # Print the final result
    print(output_string)

except ValueError:
    # Handle cases where input cannot be split or converted to int
    # According to the problem, input format is fixed, so this might not be strictly needed
    # print("Invalid input format.") 
    pass 
except Exception as e:
    # Catch other potential errors
    # print(f"An error occurred: {e}")
    pass
0