AC

张子程 · 发布于 2026-01-28 · 浏览 238 回复 0

include <bits/stdc++.h>

using namespace std;

int main() {

int m, k;
cin >> m >> k;
int P = 0, D = 0, A = 0;
for (int i = m; i <= k; i++) {
	int s = 0;
	for (int j = 1; j <= sqrt(i); j++) {
		if (i % j == 0 && j * j != i&&j!=1) {
			s += j + i / j;
		} else if (i % j == 0 && j * j == i||j==1) {
			s += j;
		}
	}
	if (s == i) {
		P++;
	} else if (s < i) {
		D++;
	} else {
		A++;
	}

}
cout << "Perfect: " << P << endl;
cout << "Deficient: " << D << endl;
cout << "Abundant: " << A;
return 0;

}

全部回复 共 0 条

还没有人回复。往下写第一条。

发表回复