이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
set<ll> ans;
ll n;
vector<ll> fac;
vector<ll> factor_tem, factor;
ll sum = 0;
void factorize(ll n, ll now, ll smallfac){
if(now == n) ans.insert(sum);
for(int i = smallfac; factor[i]*now <= n ; i++){
if((n/now) % factor[i] == 0){
fac.pb(factor[i]);
sum+=(factor[i]-1);
factorize(n, now*factor[i], i);
sum-=(factor[i]-1);
fac.pop();
}
}
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i = 1; i * i <= n; i++){
if(n%i==0) {
factor_tem.pb(i);
if(i*i!=n)factor_tem.pb(n/i);
}
}
int k = factor_tem.size();
factor.resize(k+5);
for(int i = 0; i < k/2; i++){
factor[i] = factor_tem[2*i];
factor[k-i-1] = factor_tem[2*i+1];
}
if(k%2==1) factor[k/2] = factor_tem[k-1];
factor[k] = (ll)1e10;
//for(auto i: factor) cout<<i<<' ';
factorize(n, 1, 1);
cout<<ans.size()<<endl;
for(set<ll>::iterator it = ans.begin(); it!=ans.end(); it++){
cout<<*it<<' ';
}
return 0;
}
# | 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... |