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;
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
const int INF = 1e18,N = 1e5 + 1;
const int p = 911382323, m = 972663749;
int binpow (int a, int n) {
if (n == 0)
return 1;
if (n % 2 == 1)
return (binpow(a, n - 1) * (a));
else {
int b = binpow(a, n / 2);
return (b * b) ;
}
}
set<int> res;
void when(int n,int sum){
sum += n - 1;
res.insert(sum);
sum -= n - 1;
for(int dv = 1;dv * dv <= n;dv++){
if(dv == 1){
continue;
}
if(n % dv == 0){
sum += dv - 1;
when(n / dv,sum);
sum -= dv - 1;
}
}
}
void solve(){
int n;
cin >> n;
when(n,0);
cout << res.size() << "\n";
for(auto i : res){
cout << i << " ";
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
int t = 1;
//~ cin >> t;
while(t--){
solve();
}
}
# | 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... |