# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
648431 | | ymm | Toys (CEOI18_toy) | C++17 | | 3069 ms | 90188 KiB |
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 Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
set<int> solve(int n)
{
static map<int, set<int>> mem;
if (n == 1)
return {0};
if (mem.count(n))
return mem[n];
set<int> ans;
for (int x = 2; x*x <= n; ++x) {
if (n%x)
continue;
for (int y : solve(x))
ans.insert(y+n/x-1);
for (int y : solve(n/x))
ans.insert(y+x-1);
}
ans.insert(n-1);
mem[n] = ans;
return ans;
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
int n;
cin >> n;
auto ans = solve(n);
cout << ans.size() << '\n';
for (int x : ans)
cout << x << ' ';
cout << '\n';
}
# | 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... |