Submission #548793

#TimeUsernameProblemLanguageResultExecution timeMemory
548793Vladth11Toys (CEOI18_toy)C++14
100 / 100
3155 ms4508 KiB
#include <bits/stdc++.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " using namespace std; typedef long long ll; typedef pair <ll, ll> pii; typedef pair <pair <ll, ll>, ll > ura; const ll NMAX = 1000001; const ll VMAX = 26; const ll INF = (1LL << 55); const ll MOD = 90000000000000001; const ll BLOCK = 1000000; const ll base = 1000000001; const ll nr_of_bits = 18; set <int> sol; vector <int> divisors; void bkt(int k, int n, int sum) { if(n == 1) { sol.insert(sum); return; } if(k == divisors.size()) { return; } if(n < divisors[k]) return; if(n % divisors[k] == 0) { bkt(k, n / divisors[k], sum + divisors[k] - 1); } bkt(k + 1, n, sum); } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, i; cin >> n; for(i = 1; i * i <= n; i++) { if(n % i == 0) { if(n / i == i) { divisors.push_back(i); } else { divisors.push_back(i); divisors.push_back(n / i); } } } sort(divisors.begin(), divisors.end()); bkt(1, n, 0); cout << sol.size() << "\n"; for(auto x : sol) { cout << x << " "; } return 0; }

Compilation message (stderr)

toy.cpp: In function 'void bkt(int, int, int)':
toy.cpp:26:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |    if(k == divisors.size()) {
      |       ~~^~~~~~~~~~~~~~~~~~
#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...