碎碎念
我们有 N 个奶油泡芙.
找出所有可能的人数,我们可以将奶油泡芙均匀地分配给他们而不切割它们。
Input is given from Standard Input in the following format:
N
Print the numbers of people in ascending order, each in its own line.
6
1
2
3
6
例如,我们可以将奶油泡芙平均分配给两个人,每人分三个
720
1
2
3
4
5
6
8
9
10
12
15
16
18
20
24
30
36
40
45
48
60
72
80
90
120
144
180
240
360
720
1000000007
1
1000000007
void coder_solution() {
// 提升cin、cout效率
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
long long n;
cin >> n;
set<long long> a;
for(long long i = 1; i * i <= n; ++i) {
if (n % i == 0) {
a.insert(i);
a.insert(n / i);
}
}
for(auto p : a) {
cout << p << endl;
}
}
#include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin >> N;
vector<long long> res;
for (long long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
res.push_back(i);
if (i * i != N) res.push_back(N / i);
}
}
sort(res.begin(), res.end());
for (auto v : res) cout << v << endl;
}