Submission #536884

#TimeUsernameProblemLanguageResultExecution timeMemory
536884chicken337Toys (CEOI18_toy)C++14
100 / 100
2285 ms80036 KiB
#include <bits/stdc++.h> using namespace std; #define hash long long unordered_set<hash> hset; hash get(int n, int sum){ hash res = (hash) n * 1e9l + sum; return res; } void backtrack(int n, int sum){ hash now = get(n, sum); if(hset.find(now) != hset.end()) return; hset.insert(now); for(int k = 2; k <= sqrt(n); k ++){ int div = n / k; if((div * k) == n) backtrack(div, sum + k - 1); } if(n != 1) backtrack(1, sum + n - 1); } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; backtrack(n, 0); set<int> unique; for(hash sum : hset) if(sum / (hash)1e9l == 1ll) unique.insert(sum % (hash)1e9); cout << unique.size() << '\n'; for(int it : unique) cout << it << ' '; }
#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...