728x90
6825번: Body Mass Index
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 BMI = weight/(height × height).
www.acmicpc.net
문제 풀이
문제에 제시된 BMI 공식에 맞춰 조건에 따라 출력해주면 된다.
정답 코드
C++
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define ll long long
int main() {
fast;
double w, h;
cin >> w >> h;
if (w / pow(h, 2) > 25) cout << "Overweight";
else if (w / pow(h, 2) > 18.5) cout << "Normal weight";
else cout << "Underweight";
}
python
w = float(input())
h = float(input())
if w / (h ** 2) > 25 : print("Overweight")
elif w / (h ** 2) > 18.5 : print("Normal weight")
else : print("Underweight")
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 6841 - I Speak TXTMSG [C++/python] (0) | 2023.03.02 |
---|---|
[BOJ/백준] 6840 - Who is in the middle? [C++/python] (0) | 2023.03.02 |
[BOJ/백준] 5524 - 입실 관리 [C++/python] (0) | 2023.03.02 |
[BOJ/백준] 5358 - Football Team [C++/python] (0) | 2023.03.02 |
[BOJ/백준] 5357 - Dedupe [C++/python] (0) | 2023.03.02 |