Submission #74583

#TimeUsernameProblemLanguageResultExecution timeMemory
74583szawinisToys (CEOI18_toy)C++17
100 / 100
4459 ms87560 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> divs; map<int, set<int> > dp; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 2; i <= sqrt(n); i++) if(n % i == 0) { divs.push_back(i); divs.push_back(n/i); } divs.push_back(n); sort(divs.begin(), divs.end()); divs.resize(unique(divs.begin(), divs.end()) - divs.begin()); for(int d: divs) dp[d].insert(d - 1); for(int i = 0; i < divs.size(); i++) { for(int j = 0; j < i; j++) if(divs[i] % divs[j] == 0) { for(int x: dp[divs[j]]) dp[divs[i]].insert(x + divs[i] / divs[j] - 1); } } cout << dp[n].size() << endl; for(int x: dp[n]) cout << x << ' '; cout << endl; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:19:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < divs.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...