Submission #78430

#TimeUsernameProblemLanguageResultExecution timeMemory
78430SaboonToys (CEOI18_toy)C++14
100 / 100
4748 ms87440 KiB
#include <iostream> #include <queue> #include <bitset> #include <stack> #include <vector> #include <cstring> #include <cmath> #include <unordered_map> #include <map> #include <set> #include <algorithm> #include <iomanip> #define prime first #define alpha second #define PB push_back #define PF push_front #define MP make_pair using namespace std; typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef unsigned long long ull; const int maxn = 1e5 + 100; map <int, set <ll> > dp; int n; void add (int i) { if (n % i == 0) { for (int j = 1; j <= sqrt (i); j++) { if (i % j == 0) { for (auto k : dp[i / j]) { dp[i].insert (k + j - 1); } if (j != sqrt (i)) { for (auto k : dp[j]) { dp[i].insert (k + (i / j) - 1); } } } } } } int main() { ios::sync_with_stdio(false); cin >> n; dp[1].insert (0); for (int i = 2; i <= sqrt (n); i++) add (i); for (int i = sqrt (n); i >= 1; i--) { if (n % i == 0 and dp[n / i].empty()) add (n / i); } cout << dp[n].size() << endl; for (auto w : dp[n]) cout << w << " "; cout << endl; }
#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...