Submission #156333

#TimeUsernameProblemLanguageResultExecution timeMemory
156333lycToys (CEOI18_toy)C++14
100 / 100
3454 ms91252 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef pair<ii, int> ri3; #define mp make_pair #define pb push_back #define fi first #define sc second #define SZ(x) (int)(x).size() #define ALL(x) begin(x), end(x) #define REP(i, n) for (int i = 0; i < n; ++i) #define FOR(i, a, b) for (int i = a; i <= b; ++i) #define RFOR(i, a, b) for (int i = a; i >= b; --i) int N; vector<int> d; set<int> dp[100005]; int main() { //freopen("in.txt", "r", stdin); ios::sync_with_stdio(false); cin.tie(0); cin >> N; for (int i = 1; i*i <= N; ++i) { if (N%i == 0) { d.push_back(i); if (N/i != i) d.push_back(N/i); } } sort(ALL(d)); dp[0].insert(0); for (int i = 1; i < SZ(d); ++i) { for (int j = 0; j < i; ++j) { if (d[i]%d[j] == 0) { for (auto x : dp[j]) dp[i].insert(x + d[i]/d[j] - 1); } } } cout << SZ(dp[SZ(d)-1]) << '\n'; for (auto x : dp[SZ(d)-1]) cout << x << ' '; cout << '\n'; }
#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...