Submission #599447

#TimeUsernameProblemLanguageResultExecution timeMemory
5994471binToys (CEOI18_toy)C++14
100 / 100
2686 ms86568 KiB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
int n;
vector<int> v;

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n;
    for(int i = 2; i * i <= n; i++){
        if(n % i) continue;
        v.emplace_back(i);
        if(i * i != n) v.emplace_back(n / i);
    }
    v.emplace_back(n);
    sort(all(v)); int sz = v.size();
    vector<set<int>> dp(sz);
    for(int i = 0; i < v.size(); i++){
        dp[i].emplace(v[i] - 1);
        for(int j = 0; j < i; j++){
            if(v[i] % v[j]) continue;
            for(int x : dp[j]) dp[i].emplace(v[i] / v[j] - 1 + x);
        }
    }
    cout << dp[sz - 1].size() << '\n';
    for(int x : dp[sz - 1]) cout << x << ' ';
    return 0;
}

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:22:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for(int i = 0; i < v.size(); i++){
      |                    ~~^~~~~~~~~~
#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...