damn

杨耀然  •  3个月前


include

using namespace std;

int countFactors(int num) {

int count = 0;
for (int i = 1; i * i <= num; i++) {
	if (num % i == 0) {
		if (i * i == num) {
			count++;
		} else {
			count += 2;
		}
	}
}
return count;

}

int main() {

int n, m;
cin >> n >> m;
int maxCount = 0;
int maxNum = n;
for (int i = n; i <= m; i++) {
	int curCount = countFactors(i);
	if (curCount > maxCount) {
		maxCount = curCount;
		maxNum = i;
	} else if (curCount == maxCount && i < maxNum) {
		maxNum = i;
	}
}
cout << maxNum << " " << maxCount << endl;
return 0;

}


评论:

请先登录,才能进行评论