# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
267049 | Kenzo_1114 | Toys (CEOI18_toy) | C++17 | 1 ms | 384 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;
int n, s[40];
vector<int> v;
vector<int> ans[40];
set<int> ANS;
set<int> :: iterator it;
int main ()
{
scanf("%d", &n);
int sq = sqrt(n) + 1;
for(int i = 2; i <= sq; i++)
while(n % i == 0)
n /= i, v.push_back(i);
if(n > 1) v.push_back(n);
v.push_back(0);
sort(v.begin(), v.end());
int sz = v.size();
s[0] = 1;
for(int i = 1; i < sz; i++) s[i] = s[i - 1] * v[i];
ans[0].push_back(0);
for(int i = 1; i < sz; i++)
for(int j = 1; j <= i; j++)
for(int k = 0; k < ans[j - 1].size(); k++)
ans[i].push_back(ans[j - 1][k] + s[i] / s[j - 1] - 1);
/*
for(int i = 0; i < sz; i++)
{
printf("\nans[%d] : \n", i);
for(int j = 0; j < ans[i].size(); j++) printf("%d ", ans[i][j]);
printf("\n");
}
*/
for(int i = 0; i < ans[sz - 1].size(); i++) ANS.insert(ans[sz - 1][i]);
printf("%d\n", (int) ANS.size());
for(it = ANS.begin(); it != ANS.end(); it++) printf("%d ", (*it));
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... |