Submission #267161

#TimeUsernameProblemLanguageResultExecution timeMemory
267161ly20Toys (CEOI18_toy)C++17
100 / 100
851 ms4548 KiB
#include <bits/stdc++.h> using namespace std; set <int> resp; vector <int> div1; set <int> d; void backt(int at, int tot, int mx) { //printf("%d\n", at); //int sq = min((int) sqrt(at) + 10, at); if(at == 1) { resp.insert(tot); return; } for(int i = 0; i < div1.size(); i++) { int dv = div1[i]; if(dv == 1) continue; if(dv > mx) break; if(at % dv == 0) { backt(at / dv, tot + dv - 1, dv); } } } int main() { int n; scanf("%d", &n); set <int> :: iterator it; int sq1 = min((int) sqrt(n) + 10, n); for(int i = 1; i < sq1; i++) { if(n % i == 0) { d.insert(i); d.insert(n / i); } } for(it = d.begin(); it != d.end(); it++) { div1.push_back(*it); } backt(n, 0, n); printf("%d\n", resp.size()); for(it = resp.begin(); it != resp.end(); it++) { printf("%d ", *it); } printf("\n"); return 0; }

Compilation message (stderr)

toy.cpp: In function 'void backt(int, int, int)':
toy.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i = 0; i < div1.size(); i++) {
      |                 ~~^~~~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:37:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   37 |  printf("%d\n", resp.size());
      |          ~^     ~~~~~~~~~~~
      |           |              |
      |           int            std::set<int>::size_type {aka long unsigned int}
      |          %ld
toy.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   24 |  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...