Little Jay

[C++] 백준 2417번 - 정수 제곱근 본문

알고리즘/BOJ

[C++] 백준 2417번 - 정수 제곱근

Jay, Lee 2021. 8. 8. 17:01

사실 이분 탐색으로 안풀었는데 맞았다.....

이건 맞았는데 13706번은 왜 틀린지 모르겠다

#include <iostream>
#include <cmath>
using namespace std;

int main() {

	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n;
	cin >> n;

	long long temp = sqrt(n);
	if (pow(temp, 2) == n)
		cout << temp << '\n';
	else
		cout << temp + 1 << "\n";

	return 0;
}
Comments