Submission #1039065

#TimeUsernameProblemLanguageResultExecution timeMemory
1039065slivajanToys (CEOI18_toy)C++17
0 / 100
1 ms344 KiB
#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 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...