Submission #583674

#TimeUsernameProblemLanguageResultExecution timeMemory
583674talant117408Toys (CEOI18_toy)C++17
19 / 100
1 ms324 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; #define long unsigned long #define pb push_back #define mp make_pair #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define lb lower_bound #define ub upper_bound #define sz(v) int((v).size()) #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define endl '\n' #define PI 2*acos(0.0) void solve() { int n; cin >> n; vector <int> factors; factors.pb(1); while (n%2 == 0) { factors.pb(2); n /= 2; } for (int i = 3; i*i <= n; i += 2) { while (n%i == 0) { factors.pb(i); n /= i; } } if (n > 1) factors.pb(n); for (int i = 1; i < sz(factors); i++) factors[i] *= factors[i-1]; set <int> dp[sz(factors)]; dp[0].insert(0); for (int i = 1; i < sz(factors); i++) { for (int j = i-1; j >= 0; j--) { for (auto to : dp[j]) { dp[i].insert(to+(factors[i]/factors[j]-1)); } } } cout << sz(dp[sz(factors)-1]) << endl; for (auto to : dp[sz(factors)-1]) cout << to << ' '; } int main() { do_not_disturb int t = 1; //~ cin >> t; while (t--) { solve(); } return 0; } /* */
#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...