Submission #746483

#TimeUsernameProblemLanguageResultExecution timeMemory
746483vjudge1Toys (CEOI18_toy)C++17
100 / 100
2203 ms86600 KiB
#include <bits/stdc++.h> using namespace std; const int SQ = 3200; vector<int> vec; set<int> ans[SQ]; int n , sz; void cal(int n){ for(int i = 1 ; i * i <= n ; i++){ if(n % i) continue; vec.push_back(i); if(i * i != n) vec.push_back(n / i); } } int main(){ ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); ans[0].insert(0); cin >> n; cal(n); sort(vec.begin() , vec.end()); sz = (int)vec.size(); for(int i = 1 ; i < sz ; i++){ for(int j = 0 ; j < i ; j++){ if(vec[i] % vec[j]) continue; for(auto k : ans[j]) ans[i].insert(vec[i] / vec[j] + k - 1); } } cout << (int)ans[sz - 1].size() << '\n'; for(auto k : ans[sz - 1]) cout << k << ' '; cout << '\n'; 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...