알고리즘/BOJ

백준 6779번 Who Has Seen The Wind

꾸준함. 2021. 6. 4. 02:55

문제 링크입니다: https://www.acmicpc.net/problem/6779

 

6779번: Who Has Seen The Wind

The input is two non-negative integers: h, the humidity factor, followed by M, the maximum number of hours Margaret will wait for the weather balloon to return to ground. You can assume 0 ≤ h ≤ 100 and 0 < M < 240.

www.acmicpc.net

간단한 구현 문제였습니다.

 

#include <iostream>
#include <cmath>
using namespace std;
int main(void)
{
int h, M;
cin >> h >> M;
int hour = M;
for (int t = 1; t <= M; t++)
{
if (-6 * pow(t, 4) + h * pow(t, 3) + 2 * pow(t, 2) + t <= 0)
{
cout << "The balloon first touches ground at hour: " << t << "\n";
return 0;
}
}
cout << "The balloon does not touch ground in the given time.\n";
return 0;
}
view raw .cpp hosted with ❤ by GitHub

 

개발환경:Visual Studio 2017

 

지적, 조언, 질문 환영입니다! 댓글 남겨주세요~

반응형

'알고리즘 > BOJ' 카테고리의 다른 글

백준 6794번 What is n, Daddy?  (1) 2021.06.04
백준 6780번 Sumac Sequences  (0) 2021.06.04
백준 6696번 Too Much Water  (0) 2021.06.03
백준 6609번 모기곱셈  (0) 2021.06.03
백준 6491번 Perfection  (0) 2021.06.03