# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153694 | Ruxandra985 | Toys (CEOI18_toy) | C++14 | 590 ms | 4608 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 <cstdio>
#include <set>
#include <algorithm>
using namespace std;
set <int> st;
int v[50000],elem;
void back (int n , int sum , int prev){
int d;
if (n == 1){
st.insert(sum);
}
else {
for (int i = prev; i<= elem && v[i] * v[i] <= n ; i++){
if (n%v[i] == 0)
back (n/v[i],sum + v[i] - 1,i);
}
back(1 , sum + n - 1, n);
}
}
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n,d;
fscanf (fin,"%d",&n);
d = 2;
elem = 0;
while (d*d<=n){
if (n%d == 0)
v[++elem] = d;
d++;
}
/// trb sa generez cumva toate seturile de divizori
back (n , 0 , 1);
fprintf (fout,"%d\n",st.size());
for (set <int> :: iterator it = st.begin() ; it!=st.end() ; it++){
fprintf (fout,"%d ",*it);
}
return 0;
}
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... |