Submission #161354

#TimeUsernameProblemLanguageResultExecution timeMemory
161354luciocfToys (CEOI18_toy)C++14
59 / 100
1666 ms262148 KiB
#include <bits/stdc++.h> using namespace std; int N; vector<int> ans; void solve(int n, int soma, int prod2) { if (n == 1) { if (prod2 == N) ans.push_back(soma); return; } for (int i = 1; i*i <= n; i++) { if (n%i) continue; int d = n/i; solve(n/d, soma+d-1, prod2*d); d = i; if (i != 1 && i != n/i) solve(n/d, soma+d-1, prod2*d); } } int main(void) { scanf("%d", &N); solve(N, 0, 1); sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); printf("%d\n", ans.size()); for (auto x: ans) printf("%d ", x); printf("\n"); }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:38:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", ans.size());
                 ~~~~~~~~~~^
toy.cpp:32: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...