Submission #233176

#TimeUsernameProblemLanguageResultExecution timeMemory
233176luciocfToys (CEOI18_toy)C++14
59 / 100
5058 ms512 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> d; set<int> ans; 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) 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); 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:12:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (ind >= d.size()) return;
      ~~~~^~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:41: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:27: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...