# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1167348 | SmuggingSpun | Toys (CEOI18_toy) | C++20 | 250 ms | 12824 KiB |
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
int n;
namespace sub1234{
const int lim = 1e8 + 5;
vector<int>d;
int current = 0;
bitset<lim>ans;
void play(int N, int pre){
if(N == 1){
ans.set(current);
return;
}
for(int i = pre; i < d.size() && d[i] <= N; i++){
if(N % d[i] == 0){
current += d[i] - 1;
play(N / d[i], i);
current -= d[i] - 1;
}
}
}
void solve(){
for(int i = 2; i * i <= n; i++){
if(n % i == 0){
d.emplace_back(i);
if(i * i != n){
d.emplace_back(n / i);
}
}
}
sort(d.begin(), d.end());
d.emplace_back(n);
ans.reset();
play(n, 0);
cout << ans.count() << "\n";
for(int i = 0; i <= n; i++){
if(ans.test(i)){
cout << i << " ";
}
}
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n;
if(n <= 100000000){
sub1234::solve();
}
}
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... |