Created
March 23, 2023 17:37
-
-
Save qjatn0120/8f7301219921c2d5991c997ad60d31e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
#include "debug.h" | |
#endif // DEBUG | |
#ifndef DEBUG | |
template <typename T> | |
void debug(T &x){} | |
template <typename T> | |
void debug(T &x, int i, int j){} | |
#endif // DEBUG | |
#include <bits/stdc++.h> | |
using namespace std; | |
long long int getChip(long long int dist){ | |
if(dist & 1) return ((dist + 1) / 2) * ((dist + 1) / 2) * 4; | |
return 1 + (dist / 2) * (dist / 2 + 1) * 4; | |
} | |
int main(){ | |
cin.tie(nullptr), ios::sync_with_stdio(false); | |
int T; | |
cin >> T; | |
while(T--){ | |
long long int n; | |
cin >> n; | |
long long int lo = 0, hi = 1e9; | |
while(lo < hi){ | |
long long int mid = (lo + hi) >> 1; | |
if(getChip(mid) >= n) hi = mid; | |
else lo = mid + 1; | |
} | |
cout << lo << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment