Submission #424739

#TimeUsernameProblemLanguageResultExecution timeMemory
424739A_DToys (CEOI18_toy)C++14
59 / 100
201 ms30788 KiB
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second #define du long double using namespace std; const int N=1e5+100; vector<int> vec[N]; map<ii,bool>mp; set<int> st; void bc(int n,int sum) { if(mp[{n,sum}])return; mp[{n,sum}]=1; if(n==1){ st.insert(sum); return; } for(auto x:vec[n]){ bc(n/x,sum+x-1); } } void solve() { int n; cin>>n; for(int i=2;i<=n;i++){ for(int j=1;j*j<=i;j++){ if(i%j==0){ if(j!=1)vec[i].push_back(j); if(j*j!=i)vec[i].push_back(i/j); } } } bc(n,0); cout<<st.size()<<endl; for(auto x:st)cout<<x<<" "; } main() { int t=1; //cin>>t; while(t--)solve(); }

Compilation message (stderr)

toy.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main()
      | ^~~~
#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...