Submission #233192

#TimeUsernameProblemLanguageResultExecution timeMemory
233192luciocfToys (CEOI18_toy)C++14
100 / 100
892 ms4560 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> d; set<int> ans; bool comp(int a, int b) {return a > b;} void f(int ind, int prod, int soma) { if (ind >= d.size()) return; if (prod == n) { ans.insert(soma); return; } if (1ll*prod*d[ind] <= 1ll*n && (n%(prod*d[ind]) == 0)) f(ind, prod*d[ind], soma+d[ind]-1); f(ind+1, prod, soma); } int main(void) { scanf("%d", &n); for (int i = 2; i*i <= n; i++) { if (n%i) continue; d.push_back(i); if (n/i != i) d.push_back(n/i); } d.push_back(n); sort(d.begin(), d.end(), comp); f(0, 1, 0); printf("%d\n", ans.size()); for (auto x: ans) printf("%d ", x); printf("\n"); }

Compilation message (stderr)

toy.cpp: In function 'void f(int, int, int)':
toy.cpp:14:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (ind >= d.size()) return;
      ~~~~^~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:45:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", ans.size());
                 ~~~~~~~~~~^
toy.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
#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...