Submission #986016

#TimeUsernameProblemLanguageResultExecution timeMemory
986016raphaelpToys (CEOI18_toy)C++14
79 / 100
5027 ms69516 KiB
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; if (N == 1) { cout << 1 << '\n' << 0; return 0; } vector<int> div; unordered_map<int, int> M; for (int i = 2; i <= sqrt(N); i++) { if (N % i == 0) { div.push_back(i); if (i != N / i) div.push_back(N / i); } } div.push_back(N); sort(div.begin(), div.end()); for (int i = 0; i < div.size(); i++) M[div[i]] = i; vector<set<int>> pos(div.size()); for (int i = 0; i < div.size(); i++) pos[i].insert(div[i] - 1); for (int i = 0; i < div.size(); i++) { for (int j = 0; div[j] <= sqrt(div[i]); j++) { if (div[i] % div[j] != 0) continue; if ((N % (div[i] / div[j])) != 0) continue; int x = M[div[i] / div[j]]; for (auto k : pos[j]) { for (auto l : pos[x]) { pos[i].insert(k + l); } } } } cout << pos[pos.size() - 1].size() << '\n'; for (auto i : pos[pos.size() - 1]) { cout << i << ' '; } }

Compilation message (stderr)

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