제출 #1275377

#제출 시각아이디문제언어결과실행 시간메모리
1275377tm.khoa.tmToys (CEOI18_toy)C++20
79 / 100
5094 ms4696 KiB
//I love ManchesterUnited
#include<bits/stdc++.h>
using namespace std;

#define love ManchesterUnited
#define int long long
#define pb push_back
#define FOR(i,a,b) for (int i=(a); i<=(b); i++)
#define FORD(i,b,a) for (int i=(b); i>=(a); i--)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define time() cerr << endl << "-------------Time:" << 1000.0 * clock() / CLOCKS_PER_SEC << "ms.";
#define ALL(a) (a).begin(),(a).end()
#define ii  pair<int,int>
#define iii pair<int,ii>
#define fi first
#define se second
#define endl '\n'
#define MASK(x) (1 << (x))
#define BIT(mask,i) ((mask >> i) & 1)
typedef long long ll;

template<class X, class Y>
    bool minimize(X &x, const Y &y) {
        if (x > y) {
            x = y;
            return true;
        } else return false;
    }
template<class X, class Y>
    bool maximize(X &x, const Y &y) {
        if (x < y) {
            x = y;
            return true;
        } else return false;
    }
template<class T>
    T Abs(const T &x) {
        return (x < 0 ? -x : x);
    }

//___________________________________________________________________________________________________________________________________________________________
// CODE:
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
int check[N];
map <int,int> f;
vector <int> prime, vec;
set <int> res;

vector <int> sanguoc(int val){
    vector <int> ans;
    FOR(i,2,sqrt(val)){
        if (val % i == 0) ans.pb(i);
        if (val % i != i) ans.pb(val / i);
    }
    ans.pb(val);
    sort(ALL(ans));
    ans.erase(unique(ALL(ans)),ans.end());
    return ans;
}

void dfs(int rem, int idx, int sum){
    if (rem == 1){
        res.insert(sum);
        return;
    }
    int m = vec.size();
    FOR(i,idx,m - 1){
        int d = vec[i];
        if (d > rem) break;
        if (rem % d == 0){
            dfs(rem/d,i, sum + (d - 1));
        }
    }
}

int32_t main()
{
//    freopen("test.inp","r",stdin);
//    freopen("test.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    int n; cin >> n;

    vec = sanguoc(n);

    dfs(n,0,0);

    vector <int> out(ALL(res));
    cout << out.size() << endl;
    for (int x : out) cout << x << " ";
    return 0;

}


#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...