Submission #1007876

#TimeUsernameProblemLanguageResultExecution timeMemory
1007876canonica1Toys (CEOI18_toy)C++17
100 / 100
4966 ms87688 KiB
#include <algorithm> #include <iostream> #include <vector> #include <set> using namespace std; vector<int> ans; vector<int> factors; vector<vector<int>> g; vector<set<int>> M; void rec(int n, int answer) { if(M[n].count(answer)) return; M[n].insert(answer); if (factors[n] == 1) { ans.push_back(answer); return; } for(auto d : g[n]) { rec(d, answer + factors[n] / factors[d] - 1); } } int main() { int n; cin >> n; for (int i = 1; i * i <= n; i++) { if (n % i == 0) { factors.push_back(i); if (i * i != n) { factors.push_back(n / i); } } } sort(factors.begin(), factors.end()); g.resize(factors.size()); M.resize(factors.size()); for(int i = 0; i < factors.size(); i++){ for(int j = i + 1; j < factors.size(); j++){ if(factors[j] % factors[i] == 0){ g[j].push_back(i); } } } rec(factors.size() - 1, 0); sort(ans.begin(), ans.end()); cout << ans.size() << endl; for (auto x : ans) { cout << x << " "; } }

Compilation message (stderr)

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