Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "MAHOA"
- #include <iostream>
- #include <cstdio>
- using namespace std;
- using ll = long long;
- using ld = long double;
- constexpr int N = 1e6 + 5;
- int n, cnt[N];
- void Read()
- {
- cin >> n;
- }
- void Solve()
- {
- // Sàng nguyên tố Eratosthenes
- for (int i = 2; i <= n; ++i)
- if (cnt[i] == 0)
- for (int j = i; j <= n; j += i)
- ++cnt[j];
- pair<int, int> ans = {0, 0};
- for (int i = n; i; --i)
- ans = max(ans, make_pair(cnt[i], i));
- cout << ans.second;
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement