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>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
map<ll, set<ll>> dp;
set<ll> solve(ll left) {
if (dp[left].size())return dp[left];
set<ll> ans;
rep(i, 2, sqrt(left) + 4) {
if (left % i == 0) {
set<ll> s = solve(left / i);
trav(a, s)ans.insert(a - 1 + i);
}
}
ans.insert(left - 1);
return dp[left] = ans;
}
int main() {
cin.sync_with_stdio(false);
ll n;
cin >> n;
set<ll> res = solve(n);
cout << res.size() << endl;
trav(a, res)cout << a << " ";
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... |