Submission #948348

#TimeUsernameProblemLanguageResultExecution timeMemory
948348MinbaevToys (CEOI18_toy)C++17
59 / 100
5037 ms1296 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define f first #define int long long #define s second #define pii pair<int,int> template<class T>bool umax(T &a,T b){if(a<b){a=b;return true;}return false;} template<class T>bool umin(T &a,T b){if(b<a){a=b;return true;}return false;} typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int N=1e6 + 5 ; const int inf = 1e18 + 7; const int mod = 998244353; int n,m,k; set<int>ans; vector<int>di; //~ map<pii,int>vis; void dfs(int x, int sum){ //~ vis[{x,sum}] = 1; if(x == 1){ ans.insert(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.pb(i); if(n/i != i)di.pb(n/i); } } di.pb(n); sort(all(di)); dfs(n,0); 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...