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<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
int main() {
cin.sync_with_stdio(false);
vector<ll> primes;
map<ll, bool> is_prime;
primes.push_back(2);
rep(i, 3, 1e5) {
ll val = sqrt(i);
val++;
ll ind = upper_bound(all(primes), val) - primes.begin();
bool done = true;
rep(j, 0, ind) {
if (i % primes[j] == 0) {
done = false;
break;
}
}
if (done) {
is_prime[i] = 1;
primes.push_back(i);
}
}
ll n;
cin >> n;
ll cur = n;
vector<ll> v;
rep(i, 0, primes.size()) {
if (cur % primes[i] == 0) {
v.push_back(primes[i]);
cur /= primes[i];
i--;
}
}
if (cur != 1)v.push_back(cur);
set<vector<ll>> dp;
set<vector<ll>> dp0;
vector<ll> vv;
dp0.insert(vv);
trav(fac, v) {
trav(a, dp0) {
vector<ll> ny;
rep(i, 0, a.size()) {
ny = a;
ny[i] *= fac;
sort(all(ny));
dp.insert(ny);
}
ny = a;
ny.push_back(fac);
sort(all(ny));
dp.insert(ny);
}
dp0 = dp;
dp.clear();
}
set<ll> ans;
trav(vec, dp0) {
ll val = 0;
trav(a, vec) {
val += a - 1;
}
ans.insert(val);
}
cout << ans.size() << endl;
trav(a, ans)cout << a << " ";
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... |