# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
503689 | andrei_boaca | Toys (CEOI18_toy) | C++17 | 2512 ms | 44388 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>
#pragma GCC optimize("O3")
using namespace std;
int n;
set<int> sol;
vector<int> v;
queue<vector<int>> coada;
map<vector<int>,int> vuse;
unordered_map<int,int> use;
int main()
{
cin>>n;
vector<int> a;
a.push_back(n);
coada.push(a);
vuse[a]=1;
while(!coada.empty())
{
v=coada.front();
vuse[v]=1;
coada.pop();
int suma=0;
for(int i:v)
suma+=(i-1);
sol.insert(suma);
for(int i=0;i<v.size();i++)
{
for(int d=2;d*d<=v[i];d++)
if(v[i]%d==0)
{
int y=v[i]/d;
int x=d;
int s=suma-(v[i]-1)+(x-1)+(y-1);
if(use[s]<10)
{
sol.insert(s);
vector<int> aux;
for(int j=0;j<v.size();j++)
if(j!=i)
aux.push_back(v[j]);
aux.push_back(x);
aux.push_back(y);
sort(aux.begin(),aux.end());
if(!vuse[aux])
{
vuse[aux]=1;
use[s]++;
coada.push(aux);
}
}
}
}
}
cout<<sol.size()<<'\n';
for(auto i:sol)
cout<<i<<' ';
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... |