Submission #920801

#TimeUsernameProblemLanguageResultExecution timeMemory
920801Faisal_SaqibToys (CEOI18_toy)C++17
79 / 100
5043 ms89228 KiB
#include <iostream> #include <map> #include <set> #include <bitset> #include <queue> using namespace std; const int N=1e9+1; bitset<N> vis; map<int,set<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(); 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)].insert(kp+(j-1)); if((f)!=(j*j)) { for(auto&kp:mp[f]) mp[j].insert(kp+((f/j)-1)); } } } for(auto&kp:mp[f]) mp[1].insert(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...