Submission #594828

#TimeUsernameProblemLanguageResultExecution timeMemory
594828penguinhackerToys (CEOI18_toy)C++17
100 / 100
1742 ms86968 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> f; for (int i=1; i*i<=n; ++i) { if (n%i==0) { f.push_back(i); if (i*i<n) f.push_back(n/i); } } sort(f.begin(), f.end()); set<int> dp[f.size()]; dp[0]={0}; for (int i=1; i<f.size(); ++i) { dp[i]={f[i]-1}; for (int j=1; j<i; ++j) if (f[i]%f[j]==0) { int pos=lower_bound(f.begin(), f.end(), f[i]/f[j])-f.begin(); for (int x : dp[pos]) dp[i].insert(x+f[j]-1); } //cout << f[i] << endl; } vector<int> ans(dp[f.size()-1].begin(), dp[f.size()-1].end()); cout << ans.size() << "\n"; for (int i : ans) cout << i << " "; return 0; }

Compilation message (stderr)

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