백준 21612번 (Boiling Water, C++) [BAEKJOON]

Boiling Water

https://www.acmicpc.net/problem/21612

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초1024 MB16291153108470.711%

문제

At sea level, atmospheric pressure is 100 kPa and water begins to boil at 100C.

As you go above sea level, atmospheric pressure decreases, and water boils at lower temperatures.

As you go below sea level, atmospheric pressure increases, and water boils at higher temperatures.

A formula relating atmospheric pressure to the temperature at which water begins to boil is

P = 5 × B − 400

where P is atmospheric pressure measured in kPa, and B is the temperature at which water begins to boil measured in C.

Given the temperature at which water begins to boil, determine atmospheric pressure.

Also determine if you are below sea level, at sea level, or above sea level.

Note that the science of this problem is generally correct but the values of 100C and 100 kPa are approximate and

the formula is a simplification of the exact relationship between water’s boiling point and atmospheric pressure.

입력

The input is one line containing an integer B where B ≥ 80 and B ≤ 200.

This represents the temperature in C at which water begins to boil.

출력

The output is two lines.

The first line must contain an integer which is atmospheric pressure measured in kPa.

The second line must contain the integer -1, 0, or 1.

This integer represents whether you are below sea level, at sea level, or above sea level, respectively.

예제 입력 1

99

예제 출력 1

95
1

예제 입력 2

102

예제 출력 2

110
-1

When B = 102, we can substitute into the formula and get P = 5 × 102 − 400 which equals 110.

Since 110 kPa is greater than 100 kPa, you are below sea level.

출처

Olympiad > Canadian Computing Competition & Olympiad > 2021 > CCC 2021 Junior Division 1번

알고리즘 분류


통과된 코드

#include <iostream>
using namespace std;
int _B;
int main() 
{
	cin >> _B;
	_B = 5 * _B - 400;
	cout << _B << "\n";
	if (_B > 100) cout << "-1";
	else if (_B == 100) cout << "0";
	else cout << "1";
	return 0;
}

댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

위로 스크롤