# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73472 | jiaqing23 | Toys (CEOI18_toy) | C++14 | 5026 ms | 3708 KiB |
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;
set<ll> ans;
ll n;
vector<ll> fac;
vector<ll> factor_tem, factor;
ll sum = 0;
ll k;
ll smallfac=1;
void factorize(ll now){
if(now == n) ans.insert(sum-fac.size());
for(int i = smallfac; now*factor[i] <= n ; i++){
ll k = now*factor[i];
if(n%k == 0){
fac.pb(factor[i]);
sum+=(factor[i]);
smallfac = i;
factorize(k);
sum-=(factor[i]);
fac.pop();
}
}
}
int main()
{
scanf("%lld",&n);
for(int i = 1; i * i <= n; i++){
if(n%i==0) {
factor.pb(i);
if(i*i!=n)factor_tem.pb(n/i);
}
}
reverse(factor_tem.begin(),factor_tem.end());
factor_tem.pb((ll)1e10);
factor.resize(factor_tem.size()+factor.size());
copy_backward(factor_tem.begin(),factor_tem.end(),factor.end());
factorize(1);
printf("%d\n",ans.size());
for(set<ll>::iterator it = ans.begin(); it!=ans.end(); it++){
printf("%lld ",*it);
}
return 0;
}
Compilation message (stderr)
# | 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... |