This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int, set<int>> possibleAt;
void solveFor(int num) {
if (possibleAt.find(num) != possibleAt.end()) return;
possibleAt[num].insert(num - 1);
int cur = 2;
while (cur * cur <= num) {
if (num % cur == 0) {
solveFor(cur);
solveFor(num / cur);
for (auto it = possibleAt[cur].begin(); it != possibleAt[cur].end(); it++) {
for (auto it2 = possibleAt[num / cur].begin(); it2 != possibleAt[num / cur].end(); it2++) {
possibleAt[num].insert(*it + *it2);
}
}
}
cur++;
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
solveFor(n);
cout << possibleAt[n].size() << "\n";
for (int i : possibleAt[n]) cout << i << " ";
cout << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |