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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop pop_back
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;
typedef pair<int,pair<int,int> > tri;
unordered_set<ll> ans;
ll n;
vector<ll> fac;
vector<ll> ans2;
ll sum = 0;
void factorize(ll n, ll now, ll smallfac){
if(now == n) ans.insert(sum);
for(int i = smallfac; i*now <= n ; i++){
if((n/now) % i == 0){
fac.pb(i);
sum+=(i-1);
factorize(n, now*i, i);
sum-=(i-1);
fac.pop();
}
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
factorize(n, 1, 2);
cout<<ans.size()<<endl;
for(unordered_set<ll>::iterator it = ans.begin(); it!=ans.end(); it++){
ans2.pb(*it);
}
sort(ans2.begin(), ans2.end());
for(int i = 0; i < ans2.size(); i++) cout<<ans2[i]<<' ';
return 0;
}
Compilation message (stderr)
toy.cpp: In function 'int main()':
toy.cpp:58:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < ans2.size(); i++) cout<<ans2[i]<<' ';
~~^~~~~~~~~~~~~
# | 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... |