Submission #847762

#TimeUsernameProblemLanguageResultExecution timeMemory
847762Dec0DeddToys (CEOI18_toy)C++14
100 / 100
1424 ms18912 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; #pragma GCC optimize("O3") int n; vector<int> st; void solve(int n, int s, int j) { if (n == 1) { st.push_back(s); return; } for (int i=1; i*i<=n; ++i) { if (n%i != 0) continue; if (i >= j) solve(n/i, s+i-1, i); if (n/i >= j) solve(i, s+n/i-1, n/i); } } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>n; solve(n, 0, 2); sort(st.begin(), st.end()); st.erase(unique(st.begin(), st.end()), st.end()); cout<<st.size()<<"\n"; for (auto u : st) cout<<u<<" "; cout<<"\n"; }
#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...