Submission #145862

#TimeUsernameProblemLanguageResultExecution timeMemory
145862nvmdavaToys (CEOI18_toy)C++17
100 / 100
3828 ms86752 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define ll long long map<int, set<int> > res; vector<int> divis; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; for(int i = 1; i * i <= n; i++){ if(n % i == 0){ divis.push_back(i); if(i * i != n) divis.push_back(n / i); } } divis.push_back(n); sort(divis.begin(), divis.end()); res[1].insert(0); for(int i = 1; i < divis.size(); i++){ int d = divis[i]; auto& it = res[d]; for(int j = 0; j <= i; j++){ if(d % divis[j] == 0){ for(auto& x : res[divis[j]]){ it.insert(x + d / divis[j] - 1); } } } } cout<<res[n].size()<<'\n'; for(auto& x : res[n]){ cout<<x<<' '; } }

Compilation message (stderr)

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