Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <map>
- using namespace std;
- void fact(int n, map<int, int> &facts) {
- for (int i = 2; i * i <= n; ++i) {
- while (n % i == 0) {
- facts[i]++;
- n /= i;
- }
- }
- }
- int main() {
- int n;
- cin >> n;
- set<pair<int, int>> q;
- for (int i = 1; i <= n; ++i) {
- map<int, int> facts;
- fact(i, facts);
- int res = 1;
- for (auto [p, e] : facts) {
- if (p % 4 == 1) {
- res *= 2 * e + 1;
- }
- }
- if (q.empty() || res * 4 > (*q.rbegin()).fi) {
- q.insert({res * 4, i});
- }
- }
- for (auto el : q) {
- cout << el.fi << " " << el.se << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement