Submission #133457

#TimeUsernameProblemLanguageResultExecution timeMemory
133457VardanyanToys (CEOI18_toy)C++14
19 / 100
3 ms416 KiB
#include <bits/stdc++.h> using namespace std; map<int,int> s; map<pair<int,int>,int> mp; vector<int> ans; unordered_map<long long,int> mpp; void rec(int n,int sm,int ps = 1){ long long x = (long long)sm*(long long)31; if(mpp[n+x]) return; mpp[n+x] = 1; if(n == 1){ if(!s[sm]){ ans.push_back(sm); s[sm] = 1; } return; } for(int i = ps;i*i<=n;i++){ if(n%i) continue; if(i>1){ rec(n/i,sm+i-1,ps); } int x = n/i; rec(n/x,sm+x-1,ps); } } int main(){ ios_base::sync_with_stdio(false); int n; cin>>n; rec(n,0); cout<<ans.size()<<endl; sort(ans.begin(),ans.end()); for(int i = 0;i<ans.size();i++) cout<<ans[i]<<" "; cout<<endl; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:34:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<ans.size();i++) cout<<ans[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...