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 int MAXN = 1e9 + 10;
map < int, map < int, bool > > dp;
int n, m;
vector < int > divs;
void read()
{
cin >> n;
}
void fill_divs()
{
for(int 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(int cur, int sum, int last)
{
if(dp[cur][sum])
return;
dp[cur][sum] = true;
if(cur == n)
return;
for(int i = last; i < m; i++)
{
int d = divs[i];
if(cur * d > n)
continue;
if(!dp[cur * d][sum + d - 1])
rec(cur * d, sum + d - 1, i);
}
}
void print()
{
cout << dp[n].size() << endl;
for(auto x : dp[n])
{
cout << x.first << " ";
}
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... |