Submission #78858

#TimeUsernameProblemLanguageResultExecution timeMemory
78858tmwilliamlin168Toys (CEOI18_toy)C++14
100 / 100
2226 ms17540 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> p, ans; void dfs(int x, vector<int> &p, int i, int s) { ans.push_back(s+x-1); vector<int> p2; for(; i<p.size(); ++i) if(x%p[i]==0) p2.push_back(p[i]); for(i=0; i<p2.size(); ++i) if(x/p2[i]>=p2[i]) dfs(x/p2[i], p2, i, s+p2[i]-1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i=2; i*i<=n; ++i) if(n%i==0) p.push_back(i); dfs(n, p, 0, 0); // cout << ans.size() << endl; sort(ans.begin(), ans.end()); ans.resize(unique(ans.begin(), ans.end())-ans.begin()); cout << ans.size() << "\n"; for(int ai : ans) cout << ai << " "; }

Compilation message (stderr)

toy.cpp: In function 'void dfs(int, std::vector<int>&, int, int)':
toy.cpp:10:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(; i<p.size(); ++i)
        ~^~~~~~~~~
toy.cpp:13:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0; i<p2.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...