# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
548754 |
2022-04-14T11:26:44 Z |
Vladth11 |
Toys (CEOI18_toy) |
C++14 |
|
0 ms |
0 KB |
#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 <pair <int, int>, int > > mp;
set <int> sol;
vector <int> divisors;
void bkt(int k, int n, int sum){
if(mp.find({{k, n}, sum}) != mp.end()){
return;
}
mp.insert({{k, n}, sum});
if(n == 1){
sol.insert(sum);
}
if(k == divisors.size()){
return;
}
if(n < divisors[k]) continue;
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(0, n, 0);
cout << sol.size() << "\n";
for(auto x : sol){
cout << x << " ";
}
return 0;
}
Compilation message
toy.cpp: In function 'void bkt(int, int, int)':
toy.cpp:31:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | if(k == divisors.size()){
| ~~^~~~~~~~~~~~~~~~~~
toy.cpp:34:24: error: continue statement not within a loop
34 | if(n < divisors[k]) continue;
| ^~~~~~~~