Submission #536885

#TimeUsernameProblemLanguageResultExecution timeMemory
536885siewjhToys (CEOI18_toy)C++17
100 / 100
2572 ms90940 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int sqrtn = sqrt(n); vector<int> fact; for (int i = 1; i <= sqrtn; i++) if (n % i == 0){ fact.push_back(i); if (n / i != i) fact.push_back(n / i); } sort(fact.begin(), fact.end()); int fnum = fact.size(); vector<vector<int>> ffact(fact.size()); for (int i = 0; i < fnum; i++) for (int j = 0; j < i; j++) if (fact[i] % fact[j] == 0) ffact[i].push_back(j); vector<set<int>> cumsum(fact.size()); cumsum[0].insert(0); for (int i = 0; i < fnum; i++) for (int j = 0; j < ffact[i].size(); j++) for (int csv : cumsum[ffact[i][j]]) cumsum[i].insert(csv + fact[i] / fact[ffact[i][j]] - 1); set<int> ans; for (int csv : cumsum.back()) ans.insert(csv); cout << ans.size() << '\n'; for (int x : ans) cout << x << ' '; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:22:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j = 0; j < ffact[i].size(); j++)
      |                         ~~^~~~~~~~~~~~~~~~~
#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...