#include <iostream>
#define ll unsigned long long int
using namespace std;
ll n, a;
bool condition(ll x)
{
if(x*x > a) return true;
else return false;
}
ll binary_search(ll l, ll r)
{
ll m = (l+r)/2;
if(l == r) return (m-1)*(m-1);
if(condition(m)) return binary_search(l, m);
else return binary_search(m+1, r);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i=0; i<n; i++){
cin >> a;
cout << binary_search(1, 2e9+1) << "\n";
}
return 0;
}
'Algorithm' 카테고리의 다른 글
Codeup 1430: 기억력 테스트 2 (0) | 2023.11.09 |
---|---|
BOJ 2512: 예산 (0) | 2023.11.09 |
Edmonds-Karp (2) | 2023.08.29 |
memoization 기법을 이용한 피보나치 수열 (0) | 2023.06.26 |
탐구활동 2 (0) | 2023.04.07 |