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


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


Output for Sample Input 2


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".


  • 4
    QiQi  commented on Oct. 30, 2021, 5:50 a.m.

    I put a period at the end of Overweight , Normal weight , and Underweight , ten minuets of my life wasted.

  • 9
    Chrislojet  commented on Dec. 2, 2020, 10:08 p.m. edited

    Damn, I was so confused on why I kept getting the last case wrong and then I realized I put a capital in Normal weight.

    • 2
      Keech  commented on Aug. 10, 2021, 10:54 p.m.

      lmao i did the exact same thing I was so confused

  • 1
    Lithium  commented on July 15, 2020, 2:54 a.m.

    for the "Normal weight" I had it check if it was not in between 18.5 and 25 instead of in-between

  • 1
    LucaC  commented on June 30, 2020, 1:16 p.m.

    How do you multiply decimals in python3? Mine always says,

    Traceback (most recent call last): File "", line 2, in <module> h = int(input()) ValueError: invalid literal for int() with base 10: '1.73'

    Do you have to do some weird maths formula to work your way around this?

    • 11
      sjay05  commented on June 30, 2020, 1:21 p.m.

      Instead of reading input with int(input()) read it as a float float(input()).

      • 2
        LucaC  commented on July 4, 2020, 3:11 a.m.

        Thank you! I now know how to use decimals in python maths!

  • -4
    Henry_Z  commented on June 19, 2020, 12:34 a.m.

    I got so confused when I saw the output and when I realized it was weight first and not height, I got kinda salty.😂😂😂😂😂😂😂😂