Submission #583676

#TimeUsernameProblemLanguageResultExecution timeMemory
583676talant117408Toys (CEOI18_toy)C++17
59 / 100
752 ms262144 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; set <int> dp[n+1]; dp[1].insert(0); for (int i = 2; i <= n; i++) { for (int j = 1; j*j <= i; j++) { if (i%j == 0) { for (auto to : dp[j]) { dp[i].insert(to+i/j-1); } if (i/j != j) { for (auto to : dp[i/j]) { dp[i].insert(to+j-1); } } } } } cout << sz(dp[n]) << endl; for (auto to : dp[n]) 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...