# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548781 | Vladth11 | Toys (CEOI18_toy) | C++14 | 2802 ms | 4404 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
for(int kk = k; kk < divisors.size(); kk++){
if(n < divisors[kk]) return;
if(n % divisors[kk] == 0){
bkt(kk, n / divisors[kk], sum + divisors[kk] - 1);
}
}
}
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){
if(i != 1)
divisors.push_back(i);
}else{
if(i != 1)
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |