# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538014 | jamielim | Toys (CEOI18_toy) | C++14 | 5065 ms | 120940 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;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
int n;
vector<int> memo[5000005];
vector<int> dp(int n){
if(n<100005&&!memo[n].empty())return memo[n];
set<int> s;
for(int i=2;i*i<=n;i++){
if(n%i!=0)continue;
vector<int> y=dp(n/i);
for(int j:y){
s.insert(j+i-1);
}
}
s.insert(n-1);
vector<int> ans;
for(int i:s)ans.pb(i);
if(n<5000005)memo[n]=ans;
return ans;
}
int main(){
scanf("%d",&n);
vector<int> ans=dp(n);
sort(ALL(ans));
printf("%d\n",SZ(ans));
for(int i:ans){
printf("%d ",i);
}
}
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... |