Submission #124268

# Submission time Handle Problem Language Result Execution time Memory
124268 2019-07-02T22:51:13 Z RafikHachana Toys (CEOI18_toy) C++14
0 / 100
5000 ms 256 KB
#include<bits/stdc++.h>
using namespace std;
 
int n;
int ma;
set<int> s;



void f(int r,int p,int sum)
{
  if(r==0)
  {

    if(n%p==0)
    {
      int x = n/p -1;
      //cout<<x<<endl;
      if(x>0)
      {
        s.insert(sum+x);
      }
    }
    return;
  }
  for(int i=ma+5;i>0;i--)
  {
    //v.push_back(i);
    f(r-1,p*(i+1),sum+i);
    //v.pop_back();
  }
}

int main()
{
  cin>>n;
  s.insert(n-1);
  int r = 2;
  while(true)
  {
    ma= ceil(pow(n,1.0/r));
    //cout<<ma<<endl;
    //cout<<456<<endl;
    //vector<int> w;
    f(r-1,1,0);
    //f(r,w);
    if(ma==2) break;
    r++;
  }
  cout<<s.size()<<endl;
  for(auto it:s) cout<<it<<" ";
    cout<<endl;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 5097 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5097 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5097 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5097 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5097 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -