Submission #1039065

# Submission time Handle Problem Language Result Execution time Memory
1039065 2024-07-30T12:12:16 Z slivajan Toys (CEOI18_toy) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long un;
typedef vector<un> vuc;
typedef set<un> sun;

#define vec vector
#define REP(i, a, b) for (un i = (un)a; i < (un)b; i++)
#define FEAC(i, a) for (auto&& i : a)
#define ALL(x) (x).begin(), (x).end()


map<un, sun> cache;
vuc divi;

void answer(un a){
    if (cache.count(a) != 0) return;

    sun ret;
    ret.insert(a-1);

    for(un i = 0; divi[i]*divi[i] < a; i++){
        if (a%divi[i] != 0) continue;
        
        un d = divi[i];

        answer(d);
        answer(a/d);

        FEAC(sa, cache[d]) FEAC(sb, cache[a/d]){
            ret.insert(sa + sb);
        }
    }

    cache[a] = ret;
}

void prep_div(un a){

    un sqrt_a = 1;
    while (sqrt_a * sqrt_a <= a) sqrt_a++;

    sqrt_a++;

    REP(i, 2, sqrt_a){
        if (a % i == 0) divi.push_back(i);
    }
}

int main(){
    un N;
    cin >> N;

    prep_div(N);
    answer(N);
    sun ans = cache[N];

    cout << ans.size() << endl;
    FEAC(i, ans) cout << i << " ";
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -