Submission #1167345

#TimeUsernameProblemLanguageResultExecution timeMemory
1167345SmuggingSpunToys (CEOI18_toy)C++20
39 / 100
1 ms396 KiB
#include<bits/stdc++.h>
#define taskname "B"
using namespace std;
int n;
namespace sub12{
    const int lim = 1e4 + 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 <= 10000){
        sub12::solve();
    }
}

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:47:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...