fork download
  1. #include <bits/stdc++.h>
  2. #define boost ios_base::sync_with_stdio(0); cin.tie(0);
  3. using namespace std;
  4.  
  5. #define ll long long
  6.  
  7. vector<int> p;
  8. bool t[100005];
  9.  
  10. void sang(int n) {
  11. t[0] = t[1] = true;
  12. for (int i = 2; i * i <= n; i++)
  13. if (t[i] == false)
  14. for (int j = i * i; j <= n; j += i)
  15. t[j] = true;
  16. for (int i = 2; i <= n; i++)
  17. if (t[i] == false)
  18. p.push_back(i);
  19. }
  20.  
  21. ll power(ll x, ll n) {
  22. ll p = 1;
  23. for (; n > 0; n >>= 1, x *= x)
  24. if (n & 1)
  25. p *= x;
  26. return p;
  27. }
  28.  
  29. ll s(ll n) {
  30. ll s = 1;
  31. for (ll i = 2; i * i * i <= n; i++)
  32. if (n % i == 0) {
  33. int d = 0;
  34. while (n % i == 0)
  35. d++, n /= i;
  36. s *= (pow(i, d + 1) - 1) / (i - 1);
  37. }
  38. if (n > 1)
  39. s *= (n + 1);
  40. return s;
  41. }
  42.  
  43. void solve() {
  44. sang(10000);
  45. ll mx = -1, ans;
  46. int n;
  47. cin >> n;
  48. for (int i = 1; i <= n; i++) {
  49. ll x;
  50. cin >> x;
  51. ll t = s(x);
  52. if (t > mx)
  53. mx = t, ans = x;
  54. }
  55. cout << ans;
  56. }
  57.  
  58. int main() {
  59. boost;
  60. int t = 1;
  61. while (t--) {
  62. solve();
  63. }
  64. return 0;
  65. }
Success #stdin #stdout 0s 5296KB
stdin
4
2 4 10 9
stdout
10