Advertisement
Derga

Untitled

Sep 28th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cmath>
  3. #include <queue>
  4. #include <iostream>
  5. #include <string>
  6. #include <vector>
  7.  
  8. using namespace std;
  9.  
  10. int get_result(int n) {
  11.     vector <int> a = { 1 };
  12.  
  13.     int multip = sqrt(n);
  14.     if (multip < sqrt(n)) {
  15.         multip++;
  16.     }
  17.  
  18.     int mul2 = n / multip;
  19.     if (n % multip != 0) {
  20.         mul2++;
  21.     }
  22.    
  23.     return multip + mul2 - 2;
  24.  
  25. }
  26.  
  27. int main() {
  28.     cin.tie(0);
  29.     ios_base::sync_with_stdio(false);
  30.  
  31.     int t;
  32.     cin >> t;
  33.  
  34.     while (t--) {
  35.         int n;
  36.         cin >> n;
  37.         cout << get_result(n) << endl;
  38.     }
  39.  
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement