Submission #425239

#TimeUsernameProblemLanguageResultExecution timeMemory
425239MOUF_MAHMALATToys (CEOI18_toy)C++14
100 / 100
803 ms4516 KiB
#include<bits/stdc++.h> #define all(s) s.begin(),s.end() using namespace std; typedef int ll; ll n; set<ll>ans,s; vector<ll>v; void best(ll d,ll sum,ll mx) { if(d==1) return void(ans.insert(sum)); for(ll i=0; i<v.size(); i++) { if(v[i]>mx) break; if(d%v[i]==0) best(d/v[i],sum+v[i]-1,v[i]); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(ll i=1; i*i<=n; i++) if(n%i==0) { s.insert(i); s.insert(n/i); } s.erase(s.begin()); for(auto z:s) v.push_back(z); best(n,0,n); cout<<ans.size()<<endl; for(auto z:ans) cout<<z<<" "; return 0; }

Compilation message (stderr)

toy.cpp: In function 'void best(ll, ll, ll)':
toy.cpp:12:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(ll i=0; i<v.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...