Submission #619667

#TimeUsernameProblemLanguageResultExecution timeMemory
619667BarayToys (CEOI18_toy)C++17
Compilation error
0 ms0 KiB
#include<iostream> #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:15:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   15 |         if (!(n % i))
      |         ^~
toy.cpp:16:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |             divisors.pb(i); if (i * i != n) divisors.pb(n / i);
      |                             ^~
toy.cpp:19:5: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   19 |     sort(divisors.begin(), divisors.end());
      |     ^~~~
      |     qsort
toy.cpp:25:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i = 1; i < divisors.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~
toy.cpp:28:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                 for (int x = 0; x < v[j].size(); x++) {
      |                                 ~~^~~~~~~~~~~~~
toy.cpp:35:21: error: 'unique' was not declared in this scope
   35 |         v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
      |                     ^~~~~~
toy.cpp:39:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i = 0; i < v.back().size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~