#44306: cpp解


11331076@stu.tshs.tp.edu.tw (sky)


#include <iostream>
#include <cmath>

using namespace std;

int numDivisors(int n) {
    int count = 0;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            count += 2;  // Count both i and n/i
            if (i * i == n) {
                count--;  // Adjust for perfect squares
            }
        }
    }
    return count;
}

int main() {
    int x, y;
    cin >> x >> y;

    int maxDivisors = 0;
    int maxNum = x;

    for (int i = x; i <= y; ++i) {
        int divisors = numDivisors(i);
        if (divisors > maxDivisors) {
            maxDivisors = divisors;
            maxNum = i;
        }
    }

    cout << maxNum << " " << maxDivisors << endl;
    return 0;
}