Submission #78857

#TimeUsernameProblemLanguageResultExecution timeMemory
78857tmwilliamlin168Toys (CEOI18_toy)C++14
79 / 100
5035 ms9420 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> ps, ans; void dfs(int x, int i, int s) { ans.push_back(x-1+s); for(; i<ps.size(); ++i) if(x%ps[i]==0&&x/ps[i]>=ps[i]) dfs(x/ps[i], i, s+ps[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) ps.push_back(i); dfs(n, 0, 0); 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, int, int)':
toy.cpp:9:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(; i<ps.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...