Submission #543004

#TimeUsernameProblemLanguageResultExecution timeMemory
543004sidonToys (CEOI18_toy)C++17
100 / 100
1144 ms130080 KiB
#include <bits/stdc++.h> using namespace std; int main() { long long n; cin >> n; vector<int> d; for(int i = 1; i * i <= n; ++i) { if(!(n % i)) { d.push_back(i); if(i * i != n) d.push_back(n/i); } } sort(begin(d), end(d)); int m = size(d); vector<int> a[m] {{0}}; for(int i = 0; i < m; ++i) { sort(begin(a[i]), end(a[i])); a[i].erase(unique(begin(a[i]), end(a[i])), end(a[i])); for(int j = 1; j < m; ++j) if(!(n % (1LL * d[i] * d[j]))) { int k = lower_bound(begin(d), end(d), d[i] * d[j]) - begin(d); for(const int &v : a[i]) a[k].push_back(v + d[j] - 1); } } cout << size(a[m-1]) << '\n'; for(const int &v : a[m-1]) cout << v << ' '; }
#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...