답안 #893553

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893553 2023-12-27T06:58:12 Z vjudge1 Toys (CEOI18_toy) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define int ll
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mispertion ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define F first
#define S second
#define getlast(s) (*s.rbegin())
#define debg cout << "OK\n"

const ld PI = 3.1415926535;
const int N = 2e3 + 2;
const int M = 7e6 + 1;
int mod = 1e9+7;
const int infi = INT_MAX;
const ll infl = LLONG_MAX;
const int P = 31;

int mult(int a, int b) {
    return a * 1LL * b % mod;
}

int sum(int a, int b) {
    a %= mod; 
    if (a + b < 0)
        return a + b + mod;
    if (a + b >= mod)
        return a + b - mod;
    return a + b;
}

ll binpow(ll a, ll n) {
    if (n == 0)
        return 1;
    if (n % 2 == 1) {
        return binpow(a, n - 1) * a % mod;
    } else {
        ll b = binpow(a, n / 2);
        return b * b % mod;
    }
}

vector<int> ds;
map<int, int> mp;
set<int> st;

void getans(int n, int cs = 0, int mx = 0){
    if(cs + n - 1 <= 2e3)
        return;
    if(n == 1){
        st.insert(cs);
        return;
    }
    for(auto d : ds){
        if(n % d == 0 && d >= mx)
            getans(n / d, cs + d - 1, d);
    }
}

void solve(){
    int n;
    cin >> n;
    for(int i = 2; i * i <= n; i++){
        if(n % i)
            continue;
        ds.pb(i);
        if(i * i != n)
            ds.pb(n / i);
    }
    ds.pb(n);
    getans(n);
    ds.pb(1);
    sort(all(ds));
    for(int i = 0; i < sz(ds); i++)
        mp[ds[i]] = i;
    int dp[sz(ds)][N];
    memset(dp, 0, sizeof dp);
    dp[0][0] = 1;
    for(int i = 1; i < sz(ds); i++){
        int x = ds[i];
        vector<int> da = {};
        for(auto d : ds)
            if(x % d == 0)
                da.pb(d);
        for(int s = 0; s < N; s++){
            for(auto d : da){
                if(s - d + 1 < 0)
                    continue;
                dp[i][s] |= dp[mp[x / d]][s - d + 1];
            }
        }
    }
    for(int i = 0; i < N; i++)
        if(dp[sz(ds) - 1][i])
            st.insert(i);
    cout << sz(st) << '\n';
    for(auto e : st)
        cout << e << ' ';
}   

signed main() {
    mispertion;

    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -