Submission #746477

#TimeUsernameProblemLanguageResultExecution timeMemory
746477vjudge1Toys (CEOI18_toy)C++17
59 / 100
407 ms262144 KiB
#include <bits/stdc++.h> using namespace std; const int SQ = 3200; vector<int> vec; vector<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].push_back(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(int k : ans[j]) ans[i].push_back(vec[i] / vec[j] + k - 1); } } sort(ans[sz - 1].begin() , ans[sz - 1].end()); ans[sz - 1].resize(unique(ans[sz - 1].begin() , ans[sz - 1].end()) - ans[sz - 1].begin()); cout << (int)ans[sz - 1].size() << '\n'; for(int 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...