fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define ull unsigned long long
  5. #define all(a) (a).begin(), (a).end()
  6. const int MAXN = 1e6 + 1;
  7. int D[MAXN];
  8. bool checkCP(int n) {
  9. int k = sqrt(n);
  10. return (k * k == n);
  11. }
  12. void SangUoc(int maxn) {
  13. D[1] = 1;
  14. for (int i = 2; i <= sqrt(maxn); ++i) {
  15. for (int j = i; j <= maxn / i; ++j) {
  16. if (checkCP(i * j)) {
  17. D[i * j]++;
  18. }
  19. else D[i * j] += 2;
  20. }
  21. }
  22. for (int i = 2; i <= maxn; ++i) D[i] += 2;
  23. int maxUoc = 0, result = 0;
  24. for(int i=1;i<=maxn;++i){
  25. if(D[i] > maxUoc){
  26. maxUoc = D[i];
  27. result = i;
  28. }
  29. }
  30. cout<<result;
  31. }
  32. int main() {
  33. ios_base::sync_with_stdio(false);
  34. cin.tie(0);
  35. cout.tie(0);
  36. int n;
  37. cin>>n;
  38. SangUoc(n);
  39. }
Success #stdin #stdout 0.01s 5264KB
stdin
Standard input is empty
stdout
27720