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;
#define int long long
#define in array<int, 2>
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
map<int, set<int>> crazy;
map<int, bool> vis;
void solve(int u)
{
if(vis[u])
return;
vis[u] = 1;
if(u == 1)
{
crazy[u].insert(0);
return;
}
vector<int> d;
for(int i = 2; i*i <= u; i++)
{
if(u%i)
continue;
int j = u/i;
d.pb(i); solve(i); if(j != i){ d.pb(j); solve(j); }
}
for(auto x: d)
{
for(auto vv: crazy[x])
crazy[u].insert(vv+(u/x)-1);
}
crazy[u].insert(u-1);
return;
}
signed main()
{
fast();
int n;
cin >> n; solve(n);
cout << crazy[n].size() << "\n";
for(auto tt: crazy[n])
cout << tt << " ";
cout << "\n";
return 0;
}
# | 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... |