# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1000154 | daffuwu | Toys (CEOI18_toy) | C++14 | 1 ms | 348 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;
#define fr first
#define sc second
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, tmp, cur;
vector<pair<int, vector<int> > > vc;
void process(int dv)
{
int i;
vc.push_back({dv, {}});
for (cur=1, i=vc.size()-1; i>=1; i--)
{
cur *= vc[i].fr;
for (auto x:vc[i-1].sc)
{
vc.back().sc.push_back(x+cur-1);
}
}
cur *= vc[0].fr;
vc.back().sc.push_back(cur-1);
}
int main()
{
int i, j;
scanf("%d", &n);
for (i=2, tmp=n; i*i<=n; i++)
{
for (; tmp%i == 0; tmp/=i) process(i);
}
if (tmp>1) process(tmp);
if (n == 1) vc.push_back({0, {0}});
sort(vc.back().sc.begin(), vc.back().sc.end());
vc.back().sc.resize(unique(vc.back().sc.begin(), vc.back().sc.end())-vc.back().sc.begin());
printf("%d\n", (int)vc.back().sc.size());
for (auto x:vc.back().sc) printf("%d ", x);
printf("\n");
}
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... |