fork download
  1. // بسم الله الرحمن الرحيم
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define int long long
  5. #define vi vector<int>
  6. #define pii pair<int, int>
  7. #define all(v) v.begin(), v.end()
  8. #define ln "\n"
  9. template<typename T> ostream& operator<<(ostream& os, vector<T>& v) { for (auto& i : v) os << i << ' '; return os; }
  10. template<typename T> istream& operator>>(istream& is, vector<T>& v) { for (auto& i : v) is >> i; return is; }
  11. void FastIO() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
  12. void UseFile() { freopen("file.in", "r", stdin); freopen("file.out", "w", stdout); }
  13. int MOD = 1000000007;
  14.  
  15.  
  16.  
  17.  
  18. void Erz3() {
  19. int n;
  20. cin >> n;
  21. int max = 0;
  22. int opt = 2;
  23. for (int i = 2; i <= n; ++i) {
  24. int k = n / i;
  25. int sum = i * (k * (k + 1)) / 2;
  26. if (sum > max) {
  27. max = sum;
  28. opt = i;
  29. }
  30. }
  31. cout << opt << ln;
  32. }
  33. int32_t main() {
  34.  
  35. FastIO();
  36. int t = 1;
  37. cin >> t;
  38. while (t--) Erz3();
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
2