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>
#define pb push_back
#define pf push_front
using namespace std;
#define F first
#define S second
typedef long long ll;
#define pii pair <int, int>
#define pll pair <ll, ll>
typedef long double ld;
const ll N = 2 * 1e5 + 10;
const ll mod = 1e9 + 7;
ll um(ll a, ll b){
return ((1LL * a * b) % mod + mod) % mod;
}
ll subr(ll a, ll b){
return ((1LL * a - b) % mod + mod) % mod;
}
ll binpow(ll x, ll step){
ll res = 1LL;
while(step){
if(step & 1) res = um(res, x);
x = um(x, x);
step /= 2;
}
return res;
}
ll n;
vector <ll> nw;
map <ll, bool> mp;
void calc(ll index, ll cur, ll can){
//cout << index << " "<< cur << " " << can << endl;
if(index == -1){
if(cur == n) mp[can] = true;
return;
}
calc(index - 1, cur, can);
while(true){
if(nw[index] * cur > n) break;
cur *= nw[index];
can += (nw[index] - 1);
calc(index - 1, cur, can);
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
if(n == 1){
cout << 1 << endl;
cout << 0;
return 0;
}
for(ll i = 2; i * i <= n; i++){
if(n % i == 0){
nw.pb(i);
if(n / i != i) nw.pb(n/i);
}
}
nw.pb(n);
sort(nw.begin(), nw.end());
calc((ll)nw.size() - 1, 1LL, 0LL);
cout << mp.size() << endl;
for(auto u : mp){
cout << u.F << " ";
}
//ll cnt = 0;
//vector <pll> vec;
// for(ll i = 2; i * i <= n; i++){
// while(n % i == 0){
// n /= i;
// cnt++;
// }
// if(cnt > 0) vec.pb({cnt, i});
// }
// if(n > 0) vec.pb({1, n});
// for(auto u : vec){
// cout << u.F << " "<< u.S << endl;
// }
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... |