Submission #714435

#TimeUsernameProblemLanguageResultExecution timeMemory
714435stevancvToys (CEOI18_toy)C++14
100 / 100
2949 ms4448 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 1e5 + 2; const int M = 1e6 + 2; const ll linf = 1e18; vector<int> d; set<int> ans; int kolko; void Resi(int i, int n, int s) { if (n == 1) { ans.insert(s); kolko++; return; } if (i == d.size() || n < d[i]) return; if (n % d[i] == 0) Resi(i, n / d[i], s + d[i] - 1); Resi(i + 1, n, s); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> 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); } } d.push_back(n); sort(d.begin(), d.end()); Resi(0, n, 0); cout << ans.size() << en; for (int i : ans) cout << i << sp; cout << en; return 0; }

Compilation message (stderr)

toy.cpp: In function 'void Resi(int, int, int)':
toy.cpp:21:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if (i == d.size() || n < d[i]) return;
      |         ~~^~~~~~~~~~~
#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...