答案
2023-07-13 11:00:01
发布于:浙江
#include<bits/stdc++.h>
using namespace std;
vector<int> getDivisors(int n) {
vector<int> divisors;
for (int i = 1; i*i <= n; i++) {
if (n % i == 0) {
divisors.push_back(i);
divisors.push_back(n/i);
}
}
return divisors;
}
long long n;
int main() {
cin >> n;
vector<int> divisors = getDivisors(n);
sort(divisors.begin(),divisors.end());
for (int divisor : divisors) {
cout << divisor << " ";
}
cout << endl;
return 0;
}
全部评论 1
那道题
2024-01-03 来自 浙江
0
有帮助,赞一个