This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |