Submission #426306

#TimeUsernameProblemLanguageResultExecution timeMemory
426306fskaricaToys (CEOI18_toy)C++14
100 / 100
1347 ms114496 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second const int MAX = 2e5 + 10; int n; vector <int> v; vector <int> dp[MAX]; map <int, int> mp; int main() { cin >> n; for (int i = 1; i <= sqrt(n); i++) { if (n % i != 0) continue; v.push_back(i); if (n / i != i) v.push_back(n / i); } sort(v.begin(), v.end()); for (int i = 0; i < v.size(); i++) { mp[v[i]] = i + 1; } dp[1] = {0}; int id = 0; for (auto e : v) { id++; int id2 = 0; for (auto e2 : v) { id2++; if (id < id2) break; if (e % e2 != 0) continue; for (auto e3 : dp[mp[e / e2]]) { dp[id].push_back(e3 + e2 - 1); } } sort(dp[id].begin(), dp[id].end()); dp[id].erase(unique(dp[id].begin(), dp[id].end()), dp[id].end()); } cout << dp[v.size()].size() << endl; for (auto e : dp[v.size()]) { cout << e << " "; } cout << "\n"; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
#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...