Submission #920759

#TimeUsernameProblemLanguageResultExecution timeMemory
920759Muhammad_AneeqToys (CEOI18_toy)C++17
79 / 100
5052 ms64296 KiB
/* بسم الله الرحمن الرحيم Author: (:Muhammad Aneeq:) */ #include <iostream> #include <cmath> #include <set> #include <unordered_map> using namespace std; unordered_map<int,set<int>>d; set<int> divsum(int n) { if (d.find(n)!=d.end()) return d[n]; set<int>ans; ans.insert(n-1); for (int i=2;i<=sqrt(n);i++) { if (n%i==0) { set<int>x=divsum(i); set<int>y=divsum(n/i); for (auto k:x) for (auto j:y) ans.insert(k+j); } } d[n]=ans; return ans; } inline void solve() { int n; cin>>n; set<int>ans=divsum(n); cout<<ans.size()<<endl; for (auto i:ans) cout<<i<<' '; cout<<endl; } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); solve(); }
#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...