Submission #76962

#TimeUsernameProblemLanguageResultExecution timeMemory
76962IOrtroiiiToys (CEOI18_toy)C++14
100 / 100
4134 ms18148 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> d; vector<int> vals; void brute(int pos,int prd,int sum) { if (pos == d.size()) return; if (prd == 1) { vals.push_back(sum); return; } if (prd < d[pos]) return; if (prd % d[pos] == 0) brute(pos, prd / d[pos], sum + d[pos] - 1); brute(pos + 1, prd, sum); } int main() { scanf("%d", &n); for (int i = 2; i * i <= n; ++i) if (n % i == 0) { d.push_back(i); if (i * i < n) d.push_back(n / i); } sort(d.begin(), d.end()); d.push_back(n); brute(0, n, 0); sort(vals.begin(), vals.end()); vals.resize(unique(vals.begin(), vals.end()) - vals.begin()); cout << vals.size() << '\n'; for (int i : vals) cout << i << ' '; }

Compilation message (stderr)

toy.cpp: In function 'void brute(int, int, int)':
toy.cpp:9:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if (pos == d.size()) return;
      ~~~~^~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:20: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...