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>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN = 1e9 + 10;
unordered_map < ll, unordered_map < ll, bool > > dp;
ll n, m;
vector < ll > divs;
void read()
{
cin >> n;
}
void fill_divs()
{
for(ll i = 2; i * i <= n; i++)
{
if(n % i == 0)
{
divs.push_back(i);
if(i * i != n)
divs.push_back(n / i);
}
}
divs.push_back(n);
m = divs.size();
sort(divs.begin(), divs.end());
}
void rec(ll cur, ll sum, ll last)
{
if(dp[cur][sum])
return;
dp[cur][sum] = true;
if(cur == n)
return;
for(ll i = last; i < m; i++)
{
ll d = divs[i];
if(cur * d > n)
continue;
if(!dp[cur * d][sum + d - 1])
rec(cur * d, sum + d - 1, i);
}
}
void print()
{
vector < int > p;
for(auto x : dp[n])
{
p.push_back(x.first);
}
sort(p.begin(), p.end());
cout << p.size() << endl;
for(int x : p)
{
cout << x << " ";
}
cout << endl;
}
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
fill_divs();
rec(1, 0, 0);
print();
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... |