Submission #917914

#TimeUsernameProblemLanguageResultExecution timeMemory
917914PM1Toys (CEOI18_toy)C++17
79 / 100
5037 ms5928 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int n; ll sum=1,res=0; vector<int>v,ans; void solve(int p=0){ if(sum==n){ ans.push_back(res); return ; } for(;p<v.size();p++){ if(sum*v[p]>n)return; sum*=v[p]; res+=v[p]-1; solve(p); sum/=v[p]; res-=v[p]-1; } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; int num=n; for(int i=2;i*i<=n;i++){ if(num%i)continue; v.push_back(i); if(i*i<n) v.push_back(n/i); } v.push_back(n); sort(v.begin(),v.end()); solve(); sort(ans.begin(),ans.end()); ans.resize(unique(ans.begin(),ans.end())-ans.begin()); cout<<ans.size()<<'\n'; for(auto i:ans) cout<<i<<" "; return 0; }

Compilation message (stderr)

toy.cpp: In function 'void solve(int)':
toy.cpp:12:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(;p<v.size();p++){
      |       ~^~~~~~~~~
#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...