Submission #699256

#TimeUsernameProblemLanguageResultExecution timeMemory
699256dattranxxxToys (CEOI18_toy)C++11
79 / 100
5053 ms74548 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 1e5 + 5; int n; vector<int> divi[N]; map<int, bool> vis[N]; int main() { cin.tie(0)->sync_with_stdio(0); cout.tie(0); cin >> n; vector<int> d; for (int i = 2; i * i <= n; ++i) if (n % i == 0) { d.emplace_back(i); if (i * i != n) d.emplace_back(n / i); } d.emplace_back(n); sort(d.begin(), d.end()); queue<pair<int, int>> q; q.emplace(d.size() - 1, 0); while (!q.empty()) { int i, s; tie(i, s) = q.front(); q.pop(); for (int j = 0; j < i; ++j) if (d[i] % d[j] == 0) { int k = lower_bound(d.begin(), d.end(), d[i] / d[j]) - d.begin(); if (!vis[k][s + d[j] - 1]) { q.emplace(k, s + d[j] - 1); vis[k][s + d[j] - 1] = 1; } } vis[d.size()][s + d[i] - 1] = 1; } cout << vis[d.size()].size() << '\n'; for (auto& x : vis[d.size()]) { cout << x.first << ' '; } 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...