Submission #920810

#TimeUsernameProblemLanguageResultExecution timeMemory
920810Faisal_SaqibToys (CEOI18_toy)C++17
0 / 100
0 ms348 KiB
#include <iostream> #include <map> #include <set> #include <bitset> #include <algorithm> #include <queue> using namespace std; const int N=1e9+1; bitset<N> vis; map<int,vector<int>> mp; priority_queue<int> q; int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); int n; cin>>n; q.push(n); vis[n]=1; mp[n]={0}; while(q.size()) { int f=q.top(); q.pop(); sort(begin(mp[f]),end(mp[f])); mp[f].resize(unique(begin(mp[f]),end(mp[f]))-begin(mp[f])); for(int j=2;(j*j)<=f;j++) { if(f%j==0) { if(!vis[f/j]) { vis[f/j]=1; q.push(f/j); } if(!vis[j]) { vis[j]=1; q.push(j); } for(auto&kp:mp[f]) mp[(f/j)].push_back(kp+(j-1)); if((f)!=(j*j)) { for(auto&kp:mp[f]) mp[j].push_back(kp+((f/j)-1)); } } } for(auto&kp:mp[f]) mp[1].push_back(kp+(f-1)); } cout<<mp[1].size()<<endl; for(auto j:mp[1]) { cout<<j<<' '; } cout<<endl; }
#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...