Submission #948361

#TimeUsernameProblemLanguageResultExecution timeMemory
948361MinbaevToys (CEOI18_toy)C++17
79 / 100
5103 ms54756 KiB
#include <bits/stdc++.h> using namespace std; int n,m,k; vector<int>ans; vector<int>di; map<int,map<int,bool>>vis; void dfs(int x, int sum){ vis[x][sum] = 1; if(x == 1){ ans.push_back(sum); return; } for(auto &to:di){ if(x < to)break; if(x % to == 0 && vis[x/to][sum+to-1] == 0){ dfs(x/to,sum + to-1); } } } void solve(){ cin >> n; for(int i = 2;i*i <= n;i++){ if(n % i == 0){ di.push_back(i); if(n/i != i)di.push_back(n/i); } } di.push_back(n); sort(di.begin(),di.end()); dfs(n,0); sort(ans.begin(),ans.end()); cout<<ans.size()<<"\n"; for(auto to:ans)cout << to << " "; } /* */ signed main() { ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); int tt=1;//cin>>tt>>n; while(tt--)solve(); }
#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...