Submission #406149

#TimeUsernameProblemLanguageResultExecution timeMemory
406149abdzagToys (CEOI18_toy)C++17
100 / 100
3544 ms93996 KiB
#include<bits/stdc++.h> #include<unordered_map> #define rep(i,a,b) for(int i=int(a);i<int(b);i++) #define rrep(i,a,b) for(int i=int(a);i>int(b);i--) #define all(v) v.begin(),v.end() #define trav(a,v) for(auto&a:v) #define sz(a) a.size() typedef long double ld; using namespace std; const long long inf = 1e15; typedef long long ll; typedef unsigned long long ull; map<ll, set<ll>> dp; set<ll> solve(ll left) { if (dp[left].size())return dp[left]; set<ll> ans; rep(i, 2, sqrt(left) + 4) { if (left % i == 0) { set<ll> s = solve(left / i); trav(a, s)ans.insert(a - 1 + i); } } ans.insert(left - 1); return dp[left] = ans; } int main() { cin.sync_with_stdio(false); ll n; cin >> n; set<ll> res = solve(n); cout << res.size() << endl; trav(a, res)cout << a << " "; 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...