| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1260795 | Bui_Quoc_Cuong | Toys (CEOI18_toy) | C++20 | 5093 ms | 76804 KiB | 
#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
    bool maximize(A &a, const B b) {
        if (a < b) {
            a = b;
            return true;
        } return false;
    }
template <class A, class B>
    bool minimize(A &a, const B b) {
        if (a > b) {
            a = b;
            return true;
        } return false;
    }
#define pb push_back
#define FOR(i, a, b) for(int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int)b; i--)
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;
const int N = 3e5 + 5;
const int oo = 2e9 + 29032008;
const ll INF = 1e18 + 29032008;
int n;
map <int, int> dp[2005];
void solve() {
	cin >> n;
	vector <int> v;
	for (int i = 1; i * i <= n; i++) if (n % i == 0) {
		v.push_back(i);
		if (n / i != i) v.push_back(n / i);
	}
	sort(ALL(v));
	dp[0][0] = 1;
	for (int i = 0; i < (int)v.size(); i++) {
		for (auto &x : dp[i]) {
			for (int j = 0; j < (int)v.size(); j++) {
				long long newtich = 1LL * v[j] * v[i];
				if (n % newtich != 0) continue;
				int pos = lower_bound(ALL(v), newtich) - v.begin();
				dp[pos][x.first + v[j] - 1] = 1;
			}
		}
	}
	cout << dp[(int)v.size() - 1].size() << "\n";
	for (auto &x : dp[(int)v.size() - 1]) cout << x.first << " ";
}
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    #define ko "kieuoanh"
    if (fopen(ko".inp", "r")) { 
        freopen(ko".inp", "r", stdin); 
        freopen(ko".out", "w", stdout);
    }
    int NTEST = 1; // cin >> NTEST;
    while (NTEST--) solve();
    
    cerr << "\n[Time Elapsed] " << 0.001 * clock() << "s\n";
    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... | ||||
