Files
python/TangDou/AcWing/Tree/1075_0.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

20 lines
508 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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