fork download
  1. //
  2. // @handle: imransihab0
  3.  
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. #define int long long
  7. #define pb push_back
  8. #define py cout << "WIN" << endl
  9. #define pn cout << "LOSE" << endl
  10. #define fl(a, b) for (int i = a; i < b; i++)
  11. #define flj(a, b) for (int j = a; j< b; j++)
  12. #define fll(a) for (auto &i : a)
  13. #define ssort(a) sort(a.begin(), a.end())
  14. #define ssortf(a, x) sort(a.begin(), a.end(), x)
  15. #define rvs(a) reverse(a.begin(), a.end())
  16. #define all(a) (a).begin(), (a).end()
  17. #define el cout << "\n"
  18. #define endl "\n"
  19. #define sz(a) a.size()
  20. #define FastIO() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  21.  
  22. double distance(int x, int y) {
  23. return (x*x*1.0)+(y*y*1.0);
  24. }
  25.  
  26. int count(int k) {
  27. int cnt = 0;
  28. for(int i=1; i<=k; i++) {
  29. for(int j=1; j<=k; j++) {
  30. if(distance(i, j) <= k*k) cnt++;
  31. }
  32. }
  33. cnt *= 4;
  34. cnt += (4*k);
  35. return cnt+1;
  36. }
  37.  
  38. void solve()
  39. {
  40. int n; cin >> n;
  41. // cout << (int)distance(5, 0) << endl;
  42.  
  43. int l = 1, r = 1e4, mid, ans = -1;
  44. while(l<=r) {
  45. mid = (l+r)>>1;
  46. int ff = count(mid);
  47. if(ff >= n) {
  48. ans = mid;
  49. r = mid-1;
  50. } else l = mid+1;
  51. }
  52. cout << ans << endl;
  53. }
  54.  
  55. int32_t main(){
  56. FastIO();
  57.  
  58. // int t; cin >> t;
  59. // while(t--)
  60. solve();
  61.  
  62. return 0;
  63. }
Success #stdin #stdout 0.05s 5280KB
stdin
Standard input is empty
stdout
1