Submission #920767

#TimeUsernameProblemLanguageResultExecution timeMemory
920767Muhammad_AneeqToys (CEOI18_toy)C++17
79 / 100
5018 ms72232 KiB
/* بسم الله الرحمن الرحيم Author: (:Muhammad Aneeq:) */ #include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <map> #include <cstring> using namespace std; map<int,vector<int>>d; vector<int> divsum(int n) { if (d.find(n)!=d.end()) return d[n]; vector<int>ans; ans.push_back(n-1); for (int i=2;i<=sqrt(n);i++) { if (n%i==0) { vector<int>x=divsum(i); vector<int>y=divsum(n/i); for (auto k:x) for (auto j:y) ans.push_back(k+j); } } sort(begin(ans),end(ans)); int z=unique(begin(ans),end(ans))-begin(ans); ans.resize(z); d[n]=ans; return ans; } inline void solve() { int n; cin>>n; vector<int>z=divsum(n); cout<<z.size()<<endl; for (auto i:z) 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...