Submission #825861

#TimeUsernameProblemLanguageResultExecution timeMemory
825861gagik_2007Toys (CEOI18_toy)C++17
100 / 100
3316 ms85608 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ff first #define ss second ll ttt; const ll INF=1e18; const ll MOD=1e9+7; const ll N=5007; ll n,m,k; vector<int>s; unordered_map<ll, bool>used; void recurs(ll x, ll add){ if(used[x*MOD+add])return; used[x*MOD+add]=true; s.push_back(x-1+add); for(int i=2;i*i<=x;i++){ if(x%i==0){ recurs(x/i,add+i-1); if(i*i!=x){ recurs(i,add+x/i-1); } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); cin>>n; recurs(n,0); sort(s.begin(),s.end()); auto it=unique(s.begin(),s.end()); s.resize(it-s.begin()); cout<<s.size()<<endl; for(int x:s)cout<<x<<" "; 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...