Submission #367909

#TimeUsernameProblemLanguageResultExecution timeMemory
367909ogibogi2004Toys (CEOI18_toy)C++14
100 / 100
2297 ms85764 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long ll n; unordered_set<int>v[100000]; int main() { cin>>n; vector<ll>d; for(ll i=1;i*i<=n;i++) { if(n%i==0) { d.push_back(i); if(i*i!=n) { d.push_back(n/i); } } } sort(d.begin(),d.end()); v[0].insert(0); for(int i=0;i<d.size();i++) { for(int j=i+1;j<d.size();j++) { if(d[j]%d[i]!=0)continue; for(auto xd:v[i]) { v[j].insert(xd+d[j]/d[i]-1); } } } vector<int>ans; for(auto xd:v[d.size()-1]) { ans.push_back(xd); } sort(ans.begin(),ans.end()); cout<<ans.size()<<endl; for(auto xd:ans) { cout<<xd<<" "; } cout<<endl; return 0; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:23:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |  for(int i=0;i<d.size();i++)
      |              ~^~~~~~~~~
toy.cpp:25:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for(int j=i+1;j<d.size();j++)
      |                 ~^~~~~~~~~
#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...