Submission #426338

#TimeUsernameProblemLanguageResultExecution timeMemory
426338linkretToys (CEOI18_toy)C++14
79 / 100
5066 ms75732 KiB
#include <bits/stdc++.h> using namespace std; map <int, int> m; set <int> dp [100000]; vector <int> dj; int n; set <int> rek (int x){ //cout << x << endl; set <int> s; if (dp[m[x]].size()!=0) return dp[m[x]]; if (x==1) return {0}; for (int i=0; i<dj.size(); i++){ if (sqrt(x)<dj[i]) break; else if (x%dj[i]==0){ set <int> s3, s2; if (i!=0){ s2=rek (x/dj[i]); for (auto it:s2) s3.insert (it+dj[i]-1); } s2=rek (x/(x/dj[i])); for (auto it:s2) s3.insert (it+(x/dj[i])-1); for (auto e : s3) s.insert(e); } } return dp [m[x]]=s; } int main(){ cin >> n; int now=0; dj.push_back(n); for (int i=1; i<=sqrt (n); i++){ if (n%i==0){ m [i]=now; m[n/i]=now+1; now+=2; dj.push_back(i); dj.push_back(n/i); } } sort (dj.begin(), dj.end()); set <int> ans = rek (n); cout << ans.size() << endl; for (auto it:ans) cout << it << " "; }

Compilation message (stderr)

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