이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <map>
#warning That's the baby, that's not my baby
typedef long long ll;
int n;
std::map<int, std::vector<int>> divs;
std::vector<int> answer;
void bkt(int k, int v, int prod, int sum) {
if (prod == n) {
answer.push_back(sum);
return;
}
std::vector<int> w = divs[n / prod];
for (const auto &val : w) {
if (val >= v) {
bkt(k + 1, val, prod * val, sum + val - 1);
}
}
}
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cin >> n;
std::vector<int> v;
int d = 1;
for (; d * d < n; d++) {
if (n % d == 0) {
v.push_back(d);
v.push_back(n / d);
}
}
if (d * d == n) {
v.push_back(d);
}
std::sort(v.begin(), v.end());
v.erase(v.begin());
divs[n] = v;
for (int i = 0; i < (int) v.size(); i++) {
for (int j = i; j < (int) v.size(); j++) {
if (v[j] % v[i] == 0) {
divs[v[j]].push_back(v[i]);
}
}
}
bkt(0, 1, 1, 0);
std::sort(answer.begin(), answer.end());
answer.erase(std::unique(answer.begin(), answer.end()), answer.end());
std::cout << (int) answer.size() << '\n';
for (const auto &val : answer) {
std::cout << val << ' ';
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
toy.cpp:7:2: warning: #warning That's the baby, that's not my baby [-Wcpp]
7 | #warning That's the baby, that's not my baby
| ^~~~~~~
# | 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... |