# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
70966 | MatheusLealV | Toys (CEOI18_toy) | C++17 | 2260 ms | 33720 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>
using namespace std;
int n;
vector<int> lista;
int solve(int n, int sum, int m)
{
if(n == 1) lista.push_back(sum);
for(int i = 1; i * i <= n; i++)
{
if( n % i != 0) continue;
if(i <= m and i > 1) solve(n/i, sum + i - 1, i);
int j = n/i;
if(j <= m and j > 1) solve(n/j, sum + j - 1, j);
}
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
solve(n, 0, n);
sort(lista.begin(), lista.end());
lista.erase(unique(lista.begin(), lista.end()), lista.end());
cout<<lista.size()<<"\n";
for(int i = 0; i < lista.size(); i++) cout<<lista[i]<<" ";
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... |