# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405352 | ollel | Toys (CEOI18_toy) | C++14 | 139 ms | 262148 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>
#include <iostream>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
int n;
vvi d;
vector<set<int>> dp;
void getd(){
d.resize(n+1);
rep(i, 2, n+1){
int x = 2*i;
while (x < n+1) {d[x].pb(i); x += i;}
}
}
set<int> get(int x) {
if (!(dp[x].empty())) return dp[x];
dp[x].insert(x - 1);
for (auto &y : d[x]) {
for (auto &k : get(x/y)) {
dp[x].insert(k + y - 1);
}
}
return dp[x];
}
int main(){
cin >> n;
getd();
dp.resize(n+1);
set<int> ans = get(n);
cout << ans.size() << endl;
for (auto &i : ans) cout << i << " "; cout<<endl;
}
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... |