# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
523594 | Deepesson | Toys (CEOI18_toy) | C++17 | 5097 ms | 125824 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>
std::vector<int> divisores;
std::map<int,bool> respostas;
typedef std::array<int,30> arr;
std::map<arr,bool> foi;
void processa(arr tem){
if(foi[tem])return;
foi[tem]=true;
{
int s=0;
for(auto&x:tem)if(x)s+=x-1;
respostas[s]=true;
}
for(int i=0;i!=tem.size();++i){
if(i&&tem[i]==(tem[i-1]))continue;
if(!tem[i])break;
for(int j = i+1;j<tem.size();++j){
if(j!=(i+1)&&tem[j]==tem[j-1])continue;
if(!tem[j])break;
arr prox={};
int add=(tem[i]*tem[j]);
int cur=0;
for(int k=0;k!=tem.size();++k){
if(k==i||k==j)continue;
if(!tem[k])continue;
if(tem[k]>=add&&(add!=-1)){
prox[cur]=add;
++cur;
add=-1;
}
prox[cur]=(tem[k]);
++cur;
}
if(add!=-1){
prox[cur]=add;
++cur;
}
processa(prox);
}
}
}
void achar_divisores(long long x){
for(int i=2;i!=1000000;++i){
if(!(x%i)){
while(!(x%i)){
divisores.push_back(i);
x/=i;
}
}
}
if(x>1)divisores.push_back(x);
}
int main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
long long N;
std::cin>>N;
achar_divisores(N);
arr x = {};
for(int i=0;i!=divisores.size();++i)x[i]=divisores[i];
processa(x);
std::cout<<respostas.size()<<"\n";
for(auto&x:respostas)std::cout<<x.first<<" ";
std::cout<<"\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... |