이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
unordered_map<int, unordered_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... |