Submission #113321

#TimeUsernameProblemLanguageResultExecution timeMemory
113321DiuvenToys (CEOI18_toy)C++14
100 / 100
3119 ms17232 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef pair<int, int> pii; const int INF = 2e9; const int MOD = 1e9+7; const int MAX = 1e5+10; const lint LNF = 2e18; vector<int> ans; int n; void solve(int x, int m, int sum){ if(m==1){ ans.push_back(sum); return; } for(lint d=1; d*d<=m; d++){ if(m%d==0 && d>=x) solve(d, m/d, sum+d-1); if(m%d==0 && m/d>=x) solve(m/d, d, sum+m/d-1); } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin>>n; solve(2, n, 0); sort(ans.begin(), ans.end()); ans.resize(unique(ans.begin(), ans.end())-ans.begin()); cout<<ans.size()<<'\n'; for(int x:ans) cout<<x<<' '; cout<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...