# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261826 | arnold518 | Toys (CEOI18_toy) | C++14 | 1686 ms | 110004 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>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2000;
int N;
vector<int> V;
vector<int> dp[MAXN+10];
int getcomp(int x)
{
return lower_bound(V.begin(), V.end(), x)-V.begin();
}
int main()
{
scanf("%d", &N);
for(int i=1; i*i<=N; i++)
{
if(N%i) continue;
if(i*i==N) V.push_back(i);
else
{
V.push_back(i);
V.push_back(N/i);
}
}
sort(V.begin(), V.end());
dp[0].push_back(0);
for(int i=1; i<V.size(); i++)
{
for(int j=0; j<i; j++)
{
if(V[i]%V[j]) continue;
for(auto it : dp[j]) dp[i].push_back(it+V[i]/V[j]-1);
}
sort(dp[i].begin(), dp[i].end());
dp[i].erase(unique(dp[i].begin(), dp[i].end()), dp[i].end());
}
printf("%d\n", dp[V.size()-1].size());
for(auto it : dp[V.size()-1]) printf("%d ", it);
}
Compilation message (stderr)
# | 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... |