백준 1789 c++

magicdrill·2024년 3월 1일
0

백준 문제풀이

목록 보기
72/654

백준 1789 c++

#include <iostream>

using namespace std;

unsigned long long find_result(unsigned long long S)
{
	unsigned long long result = 0, temp = 0;
	unsigned long long i = 1;

	while (1)
	{
		temp = temp + i;
		result++;
		if (temp > S)
		{
			result -= 1;
			break;
		}
		else
		{
			;
		}
		i++;
	}

	return result;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	unsigned long long S;

	cin >> S;
	cout << find_result(S) << "\n";

	return 0;
}

0개의 댓글