# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
153176 | nicolaalexandra | Toys (CEOI18_toy) | C++14 | 5071 ms | 504 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 <iostream>
#include <set>
using namespace std;
//ifstream cin ("date.in");
//ofstream cout ("date.out");
multiset <int> v;
set <int> sol;
int x,nr,d;
void back (){
if (v.size() == 1)
return;
int val = 0;
for (auto x:v)
val += x-1;
sol.insert (val);
if (v.size() == 2)
return;
/// vreau sa reduc dimensiunea cu 1
/// elimin dublurile
set <int> s;
for (auto x:v)
s.insert(x);
for (auto x:s)
for (auto y:s){
if (y > x)
continue;
/// le elimin din set si introduc produsul lor
if (x == y && v.count(x) < 2)
continue;
v.erase(v.find(x));
v.erase(v.find(y));
v.insert(x*y);
back ();
v.insert(x);
v.insert(y);
v.erase(v.find(x*y));
}}
int main (){
cin>>x;
int d = 2, nr = x;
while (nr != 1 && d <= nr/d){
int e = 0;
while (nr % d == 0){
v.insert (d); /// multiset
nr /= d;
}
d++;
}
if (nr != 1)
v.insert (nr);
back ();
sol.insert (x-1);
cout<<sol.size()<<"\n";
for (auto x:sol)
cout<<x<<" ";
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... |