Submission #548763

#TimeUsernameProblemLanguageResultExecution timeMemory
548763Vladth11Toys (CEOI18_toy)C++14
0 / 100
1 ms212 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 <pair <int, int> > mp; set <int> sol; vector <int> divisors; void bkt(int k, int n, int sum){ if(k == divisors.size()){ return; } if(mp.find({n, sum}) != mp.end()){ return; } if(n == 1){ sol.insert(sum); return; } if(n < divisors[k]) return; if(n % divisors[k] == 0){ mp.insert({n, sum}); bkt(k, n / divisors[k], sum + divisors[k] - 1); mp.erase({n, sum}); } 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()); reverse(divisors.begin(), divisors.end()); bkt(0, 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:25:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     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...