CCC '08 J1 - Body Mass Index

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2008 Stage 1, Junior #1

The Body Mass Index (BMI) is one of the calculations used by doctors to assess an adult's health. The doctor measures the patient's height (in metres) and weight (in kilograms), then calculates the BMI using the formula:

\displaystyle BMI = \frac{weight}{height \times height}

Write a program which takes the patient's weight and height as input, calculates the BMI, and displays the corresponding message from the table below.

BMI Category Message
More than 25 Overweight
Between 18.5 and 25.0 (inclusive) Normal weight
Less than 18.5 Underweight

Sample Input 1

69
1.73

Output for Sample Input 1

Normal weight

Explanation of Output for Sample Input 1

The BMI is \frac{69}{1.73 \times 1.73} which is approximately 23.0545. According to the table, this is a "Normal weight".

Sample Input 2

84.5
1.8

Output for Sample Input 2

Overweight

Explanation of Output for Sample Input 2

The BMI is \frac{84.5}{1.8 \times 1.8}, which is approximately 26.0802. According to the table, this is "Overweight".


Comments


  • 0
    eprohappy  commented on Feb. 29, 2024, 4:27 a.m.

    w = float(input()) h = float(input())

    x = w / (h * h)

    if x > 25: print("Overweight") elif 18.5 <= x <= 25: print("Normal weight")

    finish the code!