#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <sstream>
#include <stack>
#include <chrono>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
int n;
vector<int> dv;
vector<vector<int>> dvofdv;
int fnd(int x)
{
int l = 0, r = (int)dv.size() - 1;
while (l <= r)
{
int m = (l + r) / 2;
if (dv[m] == x) return m;
if (dv[m] < x) l = m + 1; else r = m - 1;
}
assert(0);
}
set<int> gustav;
void back(int x, int s, int mx)
{
assert(x >= 2);
gustav.insert(s + (x - 1));
int p = fnd(x);
for (auto& divizor : dvofdv[p])
{
if (divizor > mx) return;
if (divizor > 1 && x / divizor > 1)
{
back(x / divizor, s + (divizor - 1), divizor);
}
}
}
signed main()
{
#ifdef ONPC
FILE* stream;
freopen_s(&stream, "input.txt", "r", stdin);
#else
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
cin >> n;
for (int i = 1; i * i <= n; i++)
{
if (n % i == 0)
{
dv.push_back(i);
if (i * i == n) continue;
dv.push_back(n / i);
}
}
sort(dv.begin(), dv.end());
dvofdv.resize((int)dv.size());
for (int i = 0; i < (int)dv.size(); i++)
{
for (auto& x : dv)
{
if (x *(ll) x > dv[i]) break;
if (dv[i] % x == 0)
{
dvofdv[i].push_back(x);
if (x * x == dv[i]) continue;
dvofdv[i].push_back(dv[i] / x);
}
}
sort(dvofdv[i].begin(), dvofdv[i].end());
}
back(n, 0, n);
cout << (int)gustav.size() << "\n";
for (auto& x : gustav)
{
cout << x << " ";
}
cout << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |