Submission #975335

#TimeUsernameProblemLanguageResultExecution timeMemory
975335IBoryToys (CEOI18_toy)C++17
100 / 100
1138 ms139220 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 222222; vector<int> D, S[MAX]; int main() { int N; cin >> N; for (int i = 1; i * i <= N; ++i) { if (N % i) continue; D.push_back(i); if (i * i != N) D.push_back(N / i); } sort(D.begin(), D.end()); S[0].push_back(0); for (int i = 0; i < D.size(); ++i) { sort(S[i].begin(), S[i].end()); S[i].erase(unique(S[i].begin(), S[i].end()), S[i].end()); for (int j = i + 1; j < D.size(); ++j) { if (D[j] % D[i]) continue; for (int n : S[i]) S[j].push_back(n + D[j] / D[i] - 1); } } cout << S[D.size() - 1].size() << '\n'; for (int n : S[D.size() - 1]) cout << n << ' '; return 0; }

Compilation message (stderr)

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