# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958628 | LucaIlie | Toys (CEOI18_toy) | C++17 | 1101 ms | 112136 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;
const int MAX_DIVS = 10000;
vector<int> divs;
vector<int> sol[MAX_DIVS];
int main() {
int n;
cin >> n;
for ( int d = 1; d * d <= n; d++ ) {
if ( n % d == 0 ) {
divs.push_back( d );
if ( d != n / d )
divs.push_back( n / d );
}
}
sort( divs.begin(), divs.end() );
sol[0].push_back( 0 );
for ( int i = 1; i < divs.size(); i++ ) {
int a = divs[i];
for ( int j = 0; j < i; j++ ) {
int b = divs[j];
if ( a % b != 0 )
continue;
for ( int x: sol[j] )
sol[i].push_back( x + a / b - 1 );
}
sort( sol[i].begin(), sol[i].end() );
sol[i].resize( unique( sol[i].begin(), sol[i].end() ) - sol[i].begin() );
}
cout << sol[divs.size() - 1].size() << "\n";
for ( int x: sol[divs.size() - 1] )
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... |