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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#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;
}