You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
508 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int sum[N];
int main() {
int n = 10;
for (int i = 1; i <= n; i++) // i是因数
for (int j = 2; j <= n / i; j++) // j代表i的放大倍数 n/i不会溢出
sum[i * j] += i; // i*j的约数和+i
for (int i = 1; i <= n; i++)
cout << sum[i] << " ";
// 输出
// 0 1 1 3 1 6 1 7 4 8
// 本题要求约数和小于本身即sum[i]<i
return 0;
}