This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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()
unordered_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);
}
divi.push_back(a+1);
}
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |