Submission #933284

#TimeUsernameProblemLanguageResultExecution timeMemory
933284CookieToys (CEOI18_toy)C++14
100 / 100
3854 ms116248 KiB
#include<bits/stdc++.h> #include<fstream> using namespace std; #define sz(a) (int)a.size() #define ALL(v) v.begin(), v.end() #define ALLR(v) v.rbegin(), v.rend() #define ll long long #define pb push_back #define forr(i, a, b) for(int i = a; i < b; i++) #define dorr(i, a, b) for(int i = a; i >= b; i--) #define ld long double #define vt vector #include<fstream> #define fi first #define se second #define pll pair<ll, ll> #define pii pair<int, int> #define mpp make_pair const ld PI = 3.14159265359, prec = 1e-9;; using u128 = __uint128_t; //const int x[4] = {1, 0, -1, 0}; //const int y[4] = {0, -1, 0, 1}; const ll mod =1e9 + 7; const int mxn = 5e5 + 5, mxq = 1e5 + 5, sq = 300, mxv = 1e4 + 5; //const int base = (1 <<18); const ll inf = 3e9 + 5, neg = -69420, inf2 = 1e14; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); // have fun! // <3; int n; map<pair<int, int>, bool>mp; map<int, vt<int>>divv; vt<int>res; void solve(int n, int sm, int last = 1){ if(mp.find(mpp(n, sm)) != mp.end())return; mp[mpp(n, sm)] = 1; if(n == 1){ res.pb(sm); return; } for(auto i: divv[n]){ if(i >= last)solve(n / i, sm + i - 1, i); } } void calc(int x){ for(int i = 2; i * i <= x; i++){ if(x % i == 0){ divv[x].pb(i); if(x / i != i)divv[x].pb(x / i); } } divv[x].pb(x); } void solve(){ cin >> n; for(int i = 2; i * i <= n; i++){ if(n % i == 0){ calc(i); if(n / i != i)calc(n / i); } } calc(n); solve(n, 0); sort(ALL(res)); cout << sz(res) << "\n"; for(auto i: res)cout << i << " "; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("SODOCLA.INP", "r", stdin); //freopen("SODOCLA.INP", "w", stdout); int tt; tt = 1; while(tt--){ solve(); } return(0); } /* 10 5 2 3 4 5 6 */
#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...