Submission #619671

#TimeUsernameProblemLanguageResultExecution timeMemory
619671BarayToys (CEOI18_toy)C++17
100 / 100
3744 ms114752 KiB
#include<iostream> #include<algorithm> #include<vector> using namespace std; #define pb push_back int n; vector<int> divisors; int main() { cin >> n; for (int i = 1; i * i <= n; i++) { if (!(n % i)) divisors.pb(i); if (i * i != n) divisors.pb(n / i); } sort(divisors.begin(), divisors.end()); vector<vector<int> > v(divisors.size()); v[0].pb(0); for (int i = 1; i < divisors.size(); i++) { for (int j = 0; j < i; j++) { if (!(divisors[i] % divisors[j])) { for (int x = 0; x < v[j].size(); x++) { v[i].pb(v[j][x] + divisors[i] / divisors[j] - 1); } } } sort(v[i].begin(), v[i].end()); v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin()); } cout << v.back().size() << "\n"; for (int i = 0; i < v.back().size(); i++) { cout << v.back()[i] << " "; } }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:16:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |         if (!(n % i))
      |         ^~
toy.cpp:17:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   17 |             divisors.pb(i); if (i * i != n) divisors.pb(n / i);
      |                             ^~
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 = 1; i < divisors.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~
toy.cpp:29:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                 for (int x = 0; x < v[j].size(); x++) {
      |                                 ~~^~~~~~~~~~~~~
toy.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < v.back().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...